• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Len函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/stretchr/testify/assert.Len函数的典型用法代码示例。如果您正苦于以下问题:Golang Len函数的具体用法?Golang Len怎么用?Golang Len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Len函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestLinesWithSimilarAngle

func TestLinesWithSimilarAngle(t *testing.T) {
	examples := []struct {
		angle   float64
		lines   []polarLine
		similar []polarLine
		other   []polarLine
	}{
		{
			angle:   0,
			lines:   []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: 0.5}, polarLine{Theta: -0.49}, polarLine{Theta: -0.5}},
			similar: []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: -0.49}},
			other:   []polarLine{polarLine{Theta: 0.5}, polarLine{Theta: -0.5}},
		},
		{
			angle:   2 * math.Pi,
			lines:   []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: 0.5}, polarLine{Theta: -0.49}, polarLine{Theta: -0.5}},
			similar: []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: -0.49}},
			other:   []polarLine{polarLine{Theta: 0.5}, polarLine{Theta: -0.5}},
		},
		{
			angle:   math.Pi,
			lines:   []polarLine{polarLine{Theta: math.Pi + 0, Distance: 1}, polarLine{Theta: math.Pi + 0, Distance: 1000}, polarLine{Theta: math.Pi + 0.49}, polarLine{Theta: math.Pi + 0.5}, polarLine{Theta: math.Pi - 0.49}, polarLine{Theta: math.Pi - 0.5}},
			similar: []polarLine{polarLine{Theta: math.Pi + 0, Distance: 1}, polarLine{Theta: math.Pi + 0, Distance: 1000}, polarLine{Theta: math.Pi + 0.49}, polarLine{Theta: math.Pi - 0.49}},
			other:   []polarLine{polarLine{Theta: math.Pi + 0.5}, polarLine{Theta: math.Pi - 0.5}},
		},
		{
			angle:   math.Pi,
			lines:   []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: 0.5}, polarLine{Theta: -0.49}, polarLine{Theta: -0.5}},
			similar: []polarLine{},
			other:   []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: 0.5}, polarLine{Theta: -0.49}, polarLine{Theta: -0.5}},
		},
		{
			angle:   0,
			lines:   []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: -0.49}},
			similar: []polarLine{polarLine{Theta: 0, Distance: 1}, polarLine{Theta: 0, Distance: 1000}, polarLine{Theta: 0.49}, polarLine{Theta: -0.49}},
			other:   []polarLine{},
		},
	}

	for _, tt := range examples {
		similar, other := linesWithSimilarAngle(tt.lines, tt.angle)
		if !assert.Len(t, similar, len(tt.similar)) {
			t.Logf("Got:\n%v\nexpecting:\n%v", similar, tt.similar)
			t.FailNow()
		}
		for i, line := range similar {
			assert.InDelta(t, tt.similar[i].Theta, line.Theta, thetaDelta)
			assert.Equal(t, tt.similar[i].Distance, line.Distance)
		}

		if !assert.Len(t, other, len(tt.other)) {
			t.Logf("Got:\n%v\nexpecting:\n%v", similar, tt.similar)
			t.FailNow()
		}
		for i, line := range other {
			assert.InDelta(t, tt.other[i].Theta, line.Theta, thetaDelta)
			assert.Equal(t, tt.other[i].Distance, line.Distance)
		}
	}
}
开发者ID:mrfuxi,项目名称:sudoku,代码行数:60,代码来源:low_structures_test.go


示例2: TestMultipleGetEmpty

func TestMultipleGetEmpty(t *testing.T) {
	q := New(10)
	var wg sync.WaitGroup
	wg.Add(2)
	results := make([][]interface{}, 2)

	go func() {
		wg.Done()
		local, err := q.Get(1)
		assert.Nil(t, err)
		results[0] = local
		wg.Done()
	}()

	go func() {
		wg.Done()
		local, err := q.Get(1)
		assert.Nil(t, err)
		results[1] = local
		wg.Done()
	}()

	wg.Wait()
	wg.Add(2)

	q.Put(`a`, `b`, `c`)
	wg.Wait()

	if assert.Len(t, results[0], 1) && assert.Len(t, results[1], 1) {
		assert.True(t, (results[0][0] == `a` && results[1][0] == `b`) ||
			(results[0][0] == `b` && results[1][0] == `a`),
			`The array should be a, b or b, a`)
	}
}
开发者ID:kryptBlue,项目名称:go-datastructures,代码行数:34,代码来源:queue_test.go


示例3: TestCreateControlChannel

func TestCreateControlChannel(t *testing.T) {
	node := NewNode()
	assert.Len(t, node.controlChannels, 0, "Should be 0 control channels")
	node.AddControlChannel()
	assert.Len(t, node.controlChannels, 1, "Should be 1 control channels")
	fmt.Println("--------------------\n")
}
开发者ID:skycoin,项目名称:skycoin,代码行数:7,代码来源:node_test.go


示例4: TestContextError

func TestContextError(t *testing.T) {
	c, _, _ := CreateTestContext()
	assert.Empty(t, c.Errors)

	c.Error(errors.New("first error"))
	assert.Len(t, c.Errors, 1)
	assert.Equal(t, c.Errors.String(), "Error #01: first error\n")

	c.Error(&Error{
		Err:  errors.New("second error"),
		Meta: "some data 2",
		Type: ErrorTypePublic,
	})
	assert.Len(t, c.Errors, 2)

	assert.Equal(t, c.Errors[0].Err, errors.New("first error"))
	assert.Nil(t, c.Errors[0].Meta)
	assert.Equal(t, c.Errors[0].Type, ErrorTypePrivate)

	assert.Equal(t, c.Errors[1].Err, errors.New("second error"))
	assert.Equal(t, c.Errors[1].Meta, "some data 2")
	assert.Equal(t, c.Errors[1].Type, ErrorTypePublic)

	assert.Equal(t, c.Errors.Last(), c.Errors[1])
}
开发者ID:mrunix,项目名称:gin,代码行数:25,代码来源:context_test.go


示例5: TestGetPodContainers

//TestGetPodContainers tests the flow of GetPodContainers.
func TestGetPodContainers(t *testing.T) {
	var (
		cluster      = newRealCluster(newTimeStore, time.Minute)
		source_cache = cacheFactory()
		assert       = assert.New(t)
	)
	// Invocation with empty cluster
	res := cluster.GetPodContainers("test", "pod1")
	assert.Len(res, 0)

	// Populate cluster
	assert.NoError(cluster.Update(source_cache))

	// Normal Invocation
	res = cluster.GetPodContainers("test", "pod1")
	assert.Len(res, 2)

	// Invocation with non-existant namespace
	res = cluster.GetPodContainers("fail", "pod1")
	assert.Len(res, 0)

	// Invocation with non-existant pod
	res = cluster.GetPodContainers("test", "pod5")
	assert.Len(res, 0)
}
开发者ID:kshelton,项目名称:heapster,代码行数:26,代码来源:impl_test.go


示例6: TestEmailsService_All

func TestEmailsService_All(t *testing.T) {
	setup()
	defer tearDown()

	link := fmt.Sprintf(`<%s>; rel="next", <%s>; rel="last"`, testURLOf("/user/emails?page=2"), testURLOf("/user/emails?page=3"))
	respHeaderParams := map[string]string{"Link": link}
	stubGet(t, "/user/emails", "emails", respHeaderParams)

	url, _ := EmailUrl.Expand(nil)
	allEmails, result := client.Emails(url).All()

	assert.False(t, result.HasError())
	assert.Len(t, allEmails, 1)

	email := allEmails[0]
	assert.Equal(t, "[email protected]", email.Email)
	assert.Equal(t, true, email.Verified)
	assert.Equal(t, true, email.Primary)

	assert.Equal(t, testURLStringOf("/user/emails?page=2"), string(*result.NextPage))
	assert.Equal(t, testURLStringOf("/user/emails?page=3"), string(*result.LastPage))

	nextPageURL, err := result.NextPage.Expand(nil)
	assert.NoError(t, err)

	allEmails, result = client.Emails(nextPageURL).All()
	assert.False(t, result.HasError())
	assert.Len(t, allEmails, 1)
}
开发者ID:pcasaretto,项目名称:go-octokit,代码行数:29,代码来源:emails_test.go


示例7: TestAddBaseKeysToRoot

// adding a key to a role marks root as dirty as well as the role
func TestAddBaseKeysToRoot(t *testing.T) {
	for _, role := range data.BaseRoles {
		ed25519 := signed.NewEd25519()
		keyDB := keys.NewDB()
		repo := initRepo(t, ed25519, keyDB)

		key, err := ed25519.Create(role, data.ED25519Key)
		assert.NoError(t, err)

		assert.Len(t, repo.Root.Signed.Roles[role].KeyIDs, 1)

		assert.NoError(t, repo.AddBaseKeys(role, key))

		_, ok := repo.Root.Signed.Keys[key.ID()]
		assert.True(t, ok)
		assert.Len(t, repo.Root.Signed.Roles[role].KeyIDs, 2)
		assert.True(t, repo.Root.Dirty)

		switch role {
		case data.CanonicalSnapshotRole:
			assert.True(t, repo.Snapshot.Dirty)
		case data.CanonicalTargetsRole:
			assert.True(t, repo.Targets[data.CanonicalTargetsRole].Dirty)
		case data.CanonicalTimestampRole:
			assert.True(t, repo.Timestamp.Dirty)
		}
	}
}
开发者ID:carriercomm,项目名称:notary,代码行数:29,代码来源:tuf_test.go


示例8: TestRunningOutputFlushWhenFull

// Test that running output doesn't flush until it's full when
// FlushBufferWhenFull is set.
func TestRunningOutputFlushWhenFull(t *testing.T) {
	conf := &OutputConfig{
		Filter: Filter{
			IsActive: false,
		},
	}

	m := &mockOutput{}
	ro := NewRunningOutput("test", m, conf, 6, 10)

	// Fill buffer to 1 under limit
	for _, metric := range first5 {
		ro.AddMetric(metric)
	}
	// no flush yet
	assert.Len(t, m.Metrics(), 0)

	// add one more metric
	ro.AddMetric(next5[0])
	// now it flushed
	assert.Len(t, m.Metrics(), 6)

	// add one more metric and write it manually
	ro.AddMetric(next5[1])
	err := ro.Write()
	assert.NoError(t, err)
	assert.Len(t, m.Metrics(), 7)
}
开发者ID:mkuzmin,项目名称:telegraf,代码行数:30,代码来源:running_output_test.go


示例9: TestUpdateDelegationsRoleThatIsMissingDelegationKey

// A delegation can be created with a role that is missing a signing key, so
// long as UpdateDelegations is called with the key
func TestUpdateDelegationsRoleThatIsMissingDelegationKey(t *testing.T) {
	ed25519 := signed.NewEd25519()
	keyDB := keys.NewDB()
	repo := initRepo(t, ed25519, keyDB)

	roleKey, err := ed25519.Create("Invalid Role", data.ED25519Key)
	assert.NoError(t, err)

	role, err := data.NewRole("targets/role", 1, []string{}, []string{""}, []string{})
	assert.NoError(t, err)

	// key should get added to role as part of updating the delegation
	err = repo.UpdateDelegations(role, data.KeyList{roleKey})
	assert.NoError(t, err)

	r, ok := repo.Targets[data.CanonicalTargetsRole]
	assert.True(t, ok)
	assert.Len(t, r.Signed.Delegations.Roles, 1)
	assert.Len(t, r.Signed.Delegations.Keys, 1)
	keyIDs := r.Signed.Delegations.Roles[0].KeyIDs
	assert.Len(t, keyIDs, 1)
	assert.Equal(t, roleKey.ID(), keyIDs[0])
	assert.True(t, r.Dirty)

	// no empty delegation metadata created for new delegation
	_, ok = repo.Targets["targets/role"]
	assert.False(t, ok, "no targets file should be created for empty delegation")
}
开发者ID:carriercomm,项目名称:notary,代码行数:30,代码来源:tuf_test.go


示例10: TestDeleteDelegationsMidSliceRole

func TestDeleteDelegationsMidSliceRole(t *testing.T) {
	ed25519 := signed.NewEd25519()
	keyDB := keys.NewDB()
	repo := initRepo(t, ed25519, keyDB)

	testKey, err := ed25519.Create("targets/test", data.ED25519Key)
	assert.NoError(t, err)
	role, err := data.NewRole("targets/test", 1, []string{}, []string{""}, []string{})
	assert.NoError(t, err)

	err = repo.UpdateDelegations(role, data.KeyList{testKey})
	assert.NoError(t, err)

	role2, err := data.NewRole("targets/test2", 1, []string{}, []string{""}, []string{})
	assert.NoError(t, err)

	err = repo.UpdateDelegations(role2, data.KeyList{testKey})
	assert.NoError(t, err)

	role3, err := data.NewRole("targets/test3", 1, []string{}, []string{""}, []string{})
	assert.NoError(t, err)

	err = repo.UpdateDelegations(role3, data.KeyList{testKey})
	assert.NoError(t, err)

	err = repo.DeleteDelegation(*role2)
	assert.NoError(t, err)

	r, ok := repo.Targets[data.CanonicalTargetsRole]
	assert.True(t, ok)
	assert.Len(t, r.Signed.Delegations.Roles, 2)
	assert.Len(t, r.Signed.Delegations.Keys, 1)
	assert.True(t, r.Dirty)
}
开发者ID:carriercomm,项目名称:notary,代码行数:34,代码来源:tuf_test.go


示例11: TestSplitService

func TestSplitService(t *testing.T) {
	e := executor{}

	tests := []struct {
		description string
		service     string
		version     string
		alias       string
		alternative string
	}{
		{"service", "service", "latest", "service", ""},
		{"service:version", "service", "version", "service", ""},
		{"namespace/service", "namespace/service", "latest", "namespace__service", "namespace-service"},
		{"namespace/service:version", "namespace/service", "version", "namespace__service", "namespace-service"},
	}

	for _, test := range tests {
		service, version, linkNames := e.splitServiceAndVersion(test.description)

		assert.Equal(t, test.service, service, "for", test.description)
		assert.Equal(t, test.version, version, "for", test.description)
		assert.Equal(t, test.alias, linkNames[0], "for", test.description)
		if test.alternative != "" {
			assert.Len(t, linkNames, 2, "for", test.description)
			assert.Equal(t, test.alternative, linkNames[1], "for", test.description)
		} else {
			assert.Len(t, linkNames, 1, "for", test.description)
		}
	}
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:30,代码来源:executor_docker_test.go


示例12: TestPutLinesIntoBucketsReuseLineIfBucketsHaveSlightlyDifferent

func TestPutLinesIntoBucketsReuseLineIfBucketsHaveSlightlyDifferent(t *testing.T) {
	buckets := map[float64][]angleBucket{
		1.0: {angleBucket{0, 2}},
		2.0: {angleBucket{1, 3}},
	}

	lines := []polarLine{
		polarLine{Theta: 1},
		polarLine{Theta: 1.1},
		polarLine{Theta: 2.1},
	}

	expected := map[float64][]polarLine{
		1.0: {polarLine{Theta: 1}, polarLine{Theta: 1.1}},
		2.0: {polarLine{Theta: 1}, polarLine{Theta: 1.1}, polarLine{Theta: 2.1}},
	}

	bucketed := putLinesIntoBuckets(buckets, lines)
	assert.Len(t, bucketed, len(expected))
	for angle, expected_lines := range expected {
		if !assert.Len(t, bucketed[angle], len(expected_lines)) {
			t.FailNow()
		}

		for i, line := range bucketed[angle] {
			assert.EqualValues(t, expected_lines[i], line)
		}
	}
}
开发者ID:mrfuxi,项目名称:sudoku,代码行数:29,代码来源:low_structures_test.go


示例13: TestPutLinesIntoBuckets

func TestPutLinesIntoBuckets(t *testing.T) {
	buckets := map[float64][]angleBucket{
		0.0: {angleBucket{-0.1, 0.1}, angleBucket{math.Pi - 0.1, math.Pi + 0.1}},
		1.0: {angleBucket{0.9, 1.1}},
	}

	lines := []polarLine{
		polarLine{Theta: 0},
		polarLine{Theta: -0.1},
		polarLine{Theta: 0.1},
		polarLine{Theta: math.Pi},
		polarLine{Theta: 1.1},
		polarLine{Theta: 100},
		polarLine{Theta: -0.11},
		polarLine{Theta: 0.11},
	}

	expected := map[float64][]polarLine{
		0.0: {polarLine{Theta: 0}, polarLine{Theta: -0.1}, polarLine{Theta: 0.1}, polarLine{Theta: math.Pi}},
		1.0: {polarLine{Theta: 1.1}},
	}

	bucketed := putLinesIntoBuckets(buckets, lines)
	assert.Len(t, bucketed, len(expected))
	for angle, expected_lines := range expected {
		if !assert.Len(t, bucketed[angle], len(expected_lines)) {
			t.FailNow()
		}

		for i, line := range bucketed[angle] {
			assert.EqualValues(t, expected_lines[i], line)
		}
	}
}
开发者ID:mrfuxi,项目名称:sudoku,代码行数:34,代码来源:low_structures_test.go


示例14: TestTelegrafParseLine

func TestTelegrafParseLine(t *testing.T) {

	s := Telegraf{}
	r, err := s.ParseLine("> mem,host=ubuntu available_percent=78.43483331332489,buffered=199602176i,used=1802661888i,used_percent=21.56516668667511 1469886743")
	require.NoError(t, err)

	assert.Len(t, r.Elements, 4)
	for _, line := range r.Elements {
		assert.Equal(t, line.Plugin, "telegraf.mem")

		validGauges := []string{"mem_available.percent", "mem_buffered", "mem_used", "mem_used.percent"}
		sort.Strings(validGauges)
		i := sort.SearchStrings(validGauges, line.Gauge)
		var gaugeFound = i < len(validGauges) && validGauges[i] == line.Gauge
		assert.True(t, gaugeFound, "Valid Gauge Name")

	}

	r, err = s.ParseLine("> system,host=ubuntu load1=0.11,load15=0.06,load5=0.05,n_cpus=4i,n_users=2i,uptime=7252i 1469891972000000000")
	require.NoError(t, err)
	assert.Len(t, r.Elements, 6)

	for _, line := range r.Elements {
		assert.Equal(t, line.Plugin, "telegraf.system")

		validGauges := []string{"system_load1", "system_load15", "system_load5", "system_n.cpus", "system_n.users", "system_uptime"}
		sort.Strings(validGauges)
		i := sort.SearchStrings(validGauges, line.Gauge)
		var gaugeFound = i < len(validGauges) && validGauges[i] == line.Gauge
		assert.True(t, gaugeFound, "Valid Gauge Name")

	}

}
开发者ID:amonapp,项目名称:amonagent,代码行数:34,代码来源:telegraf_test.go


示例15: TestRunningOutputWriteFail

func TestRunningOutputWriteFail(t *testing.T) {
	conf := &OutputConfig{
		Filter: Filter{
			IsActive: false,
		},
	}

	m := &mockOutput{}
	m.failWrite = true
	ro := NewRunningOutput("test", m, conf, 4, 12)

	// Fill buffer to limit twice
	for _, metric := range first5 {
		ro.AddMetric(metric)
	}
	for _, metric := range next5 {
		ro.AddMetric(metric)
	}
	// no successful flush yet
	assert.Len(t, m.Metrics(), 0)

	// manual write fails
	err := ro.Write()
	require.Error(t, err)
	// no successful flush yet
	assert.Len(t, m.Metrics(), 0)

	m.failWrite = false
	err = ro.Write()
	require.NoError(t, err)

	assert.Len(t, m.Metrics(), 10)
}
开发者ID:mkuzmin,项目名称:telegraf,代码行数:33,代码来源:running_output_test.go


示例16: verifyCacheFactoryCluster

// verifyCacheFactoryCluster performs assertions over a ClusterInfo structure,
// based on the values and structure generated by cacheFactory.
func verifyCacheFactoryCluster(clinfo *ClusterInfo, t *testing.T) {
	assert := assert.New(t)
	assert.NotNil(clinfo.Nodes["hostname2"])
	node2 := clinfo.Nodes["hostname2"]
	assert.NotEmpty(node2.Metrics)
	assert.Len(node2.FreeContainers, 1)
	assert.NotNil(node2.FreeContainers["free_container1"])

	assert.NotNil(clinfo.Nodes["hostname3"])
	node3 := clinfo.Nodes["hostname3"]
	assert.NotEmpty(node3.Metrics)

	assert.NotNil(clinfo.Namespaces["test"])
	namespace := clinfo.Namespaces["test"]

	assert.NotNil(namespace.Pods)
	pod1_ptr := namespace.Pods["pod1"]
	require.NotNil(t, pod1_ptr)
	assert.Equal(pod1_ptr, node2.Pods["pod1"])
	assert.Len(pod1_ptr.Containers, 2)
	pod2_ptr := namespace.Pods["pod2"]
	require.NotNil(t, pod2_ptr)
	assert.Equal(pod2_ptr, node3.Pods["pod2"])
	assert.Len(pod2_ptr.Containers, 2)
}
开发者ID:kshelton,项目名称:heapster,代码行数:27,代码来源:impl_test.go


示例17: TestReadModifiedRefs

func TestReadModifiedRefs(t *testing.T) {
	client := new(ApiClient)
	client.Init()

	project := new(types.Project)
	project.SetFQName("domain", []string{"default-domain", "p1"})
	assert.NoError(t, client.Create(project))

	net := new(types.VirtualNetwork)
	net.SetFQName("project", []string{"default-domain", "p1", "n1"})
	assert.NoError(t, client.Create(net))

	vmi1 := new(types.VirtualMachineInterface)
	vmi1.SetFQName("project", []string{"default-domain", "p1", "port1"})
	vmi1.AddVirtualNetwork(net)
	assert.NoError(t, client.Create(vmi1))

	vmi2 := new(types.VirtualMachineInterface)
	vmi2.SetFQName("project", []string{"default-domain", "p1", "port2"})
	vmi2.AddVirtualNetwork(net)
	assert.NoError(t, client.Create(vmi2))

	refs, err := net.GetVirtualMachineInterfaceBackRefs()
	assert.NoError(t, err)
	assert.Len(t, refs, 2)

	assert.NoError(t, client.Delete(vmi1))
	refs, err = net.GetVirtualMachineInterfaceBackRefs()
	assert.NoError(t, err)
	assert.Len(t, refs, 1)
}
开发者ID:hkumarmk,项目名称:contrail-go-api,代码行数:31,代码来源:updater_test.go


示例18: TestAppendix_B

func TestAppendix_B(t *testing.T) {
	var jwksrc = []byte(`{"keys":
       [
        {"kty":"RSA",
         "use":"sig",
         "kid":"1b94c",
         "n":"vrjOfz9Ccdgx5nQudyhdoR17V-IubWMeOZCwX_jj0hgAsz2J_pqYW08PLbK_PdiVGKPrqzmDIsLI7sA25VEnHU1uCLNwBuUiCO11_-7dYbsr4iJmG0Qu2j8DsVyT1azpJC_NG84Ty5KKthuCaPod7iI7w0LK9orSMhBEwwZDCxTWq4aYWAchc8t-emd9qOvWtVMDC2BXksRngh6X5bUYLy6AyHKvj-nUy1wgzjYQDwHMTplCoLtU-o-8SNnZ1tmRoGE9uJkBLdh5gFENabWnU5m1ZqZPdwS-qo-meMvVfJb6jJVWRpl2SUtCnYG2C32qvbWbjZ_jBPD5eunqsIo1vQ",
         "e":"AQAB",
         "x5c": ["MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDAeFw0xMzAyMjEyMzI5MTVaFw0xODA4MTQyMjI5MTVaMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL64zn8/QnHYMeZ0LncoXaEde1fiLm1jHjmQsF/449IYALM9if6amFtPDy2yvz3YlRij66s5gyLCyO7ANuVRJx1NbgizcAblIgjtdf/u3WG7K+IiZhtELto/A7Fck9Ws6SQvzRvOE8uSirYbgmj6He4iO8NCyvaK0jIQRMMGQwsU1quGmFgHIXPLfnpnfajr1rVTAwtgV5LEZ4Iel+W1GC8ugMhyr4/p1MtcIM42EA8BzE6ZQqC7VPqPvEjZ2dbZkaBhPbiZAS3YeYBRDWm1p1OZtWamT3cEvqqPpnjL1XyW+oyVVkaZdklLQp2Btgt9qr21m42f4wTw+Xrp6rCKNb0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAh8zGlfSlcI0o3rYDPBB07aXNswb4ECNIKG0CETTUxmXl9KUL+9gGlqCz5iWLOgWsnrcKcY0vXPG9J1r9AqBNTqNgHq2G03X09266X5CpOe1zFo+Owb1zxtp3PehFdfQJ610CDLEaS9V9Rqp17hCyybEpOGVwe8fnk+fbEL2Bo3UPGrpsHzUoaGpDftmWssZkhpBJKVMJyf/RuP2SmmaIzmnw9JiSlYhzo4tpzd5rFXhjRbg4zW9C+2qok+2+qDM1iJ684gPHMIY8aLWrdgQTxkumGmTqgawR+N5MDtdPTEQ0XfIBc2cJEUyMTY5MPvACWpkA6SdS4xSvdXK3IVfOWA=="]}
       ]
     }`)

	set, err := Parse(jwksrc)
	if !assert.NoError(t, err, "Parse should succeed") {
		return
	}
	if !assert.Len(t, set.Keys, 1, "There should be 1 key") {
		return
	}

	{
		key, ok := set.Keys[0].(*RsaPublicKey)
		if !assert.True(t, ok, "set.Keys[0] should be a RsaPublicKey") {
			return
		}
		if !assert.Len(t, key.X509CertChain, 1, "key.X509CertChain should be 1 cert") {
			return
		}
	}
}
开发者ID:lestrrat,项目名称:go-jwx,代码行数:30,代码来源:jwk_test.go


示例19: TestPublicNetworkSubnetChange

// The Public network subnet configuration may change.
func TestPublicNetworkSubnetChange(t *testing.T) {
	client := new(contrail_mocks.ApiClient)
	client.Init()

	config := new(Config)
	config.PublicNetwork = "default-domain:default-project:Public"
	config.PublicSubnet = "192.0.2.0/24"
	netman := NewNetworkManager(client, config)

	// No public IP addresses are assigned: expect the public network to
	// have a single subnet.
	config.PublicSubnet = "198.51.100.0/24"
	netman = NewNetworkManager(client, config)

	network := netman.GetPublicNetwork()
	refs, err := network.GetNetworkIpamRefs()
	require.NoError(t, err)
	assert.Len(t, refs, 1)
	if len(refs) > 0 {
		attr := refs[0].Attr.(types.VnSubnetsType)
		assert.Len(t, attr.IpamSubnets, 1)
		if len(attr.IpamSubnets) > 0 {
			prefix := fmt.Sprintf("%s/%d",
				attr.IpamSubnets[0].Subnet.IpPrefix,
				attr.IpamSubnets[0].Subnet.IpPrefixLen)
			assert.Equal(t, config.PublicSubnet, prefix)
		}
	}
}
开发者ID:pupapaik,项目名称:contrail-kubernetes,代码行数:30,代码来源:network_test.go


示例20: TestRemoveMultikeysAbortChoice

// If there is more than one key, removeKeyInteractively will ask which key to
// delete.  Then it will confirm whether they want to delete, and the user can
// abort at that confirmation.
func TestRemoveMultikeysAbortChoice(t *testing.T) {
	in := bytes.NewBuffer([]byte("1\nn\n"))

	key, err := trustmanager.GenerateED25519Key(rand.Reader)
	assert.NoError(t, err)

	stores := []trustmanager.KeyStore{
		trustmanager.NewKeyMemoryStore(ret),
		trustmanager.NewKeyMemoryStore(ret),
	}

	err = stores[0].AddKey(key.ID(), "root", key)
	assert.NoError(t, err)

	err = stores[1].AddKey("gun/"+key.ID(), "target", key)
	assert.NoError(t, err)

	var out bytes.Buffer

	err = removeKeyInteractively(stores, key.ID(), in, &out)
	assert.NoError(t, err) // no error to abort deleting
	text, err := ioutil.ReadAll(&out)
	assert.NoError(t, err)

	assert.Len(t, stores[0].ListKeys(), 1)
	assert.Len(t, stores[1].ListKeys(), 1)

	// It should have listed the keys, asked whether the user really wanted to
	// delete, and then aborted.
	output := string(text)
	assert.Contains(t, output, "Found the following matching keys")
	assert.Contains(t, output, "Are you sure")
	assert.Contains(t, output, "Aborting action")
}
开发者ID:carriercomm,项目名称:notary,代码行数:37,代码来源:keys_test.go



注:本文中的github.com/stretchr/testify/assert.Len函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.New函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.JSONEq函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap