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

Golang require.Len函数代码示例

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

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



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

示例1: TestAvailLinodePlansIntegration

func TestAvailLinodePlansIntegration(t *testing.T) {
	c := NewClient(apiKey)

	plans, err := c.AvailLinodePlans(nil)
	require.NoError(t, err)
	require.NotEmpty(t, plans)

	testPlanNotEmpty(t, plans)

	// Spot check
	plans, err = c.AvailLinodePlans(Int(1))
	require.NoError(t, err)
	require.Len(t, plans, 1)

	p := plans[0]

	assert.Equal(t, 1, p.Cores)
	assert.Equal(t, 10.00, p.Price)
	assert.Equal(t, 1024, p.RAM)
	assert.Equal(t, 2000, p.Xfer)
	assert.Equal(t, 1, p.ID)
	assert.Equal(t, "Linode 1024", p.Label)
	assert.Equal(t, 24, p.Disk)
	assert.Equal(t, 0.015, p.Hourly)

	plans, err = c.AvailLinodePlans(Int(3498230))
	require.NoError(t, err)
	require.Empty(t, plans)
}
开发者ID:alexsacr,项目名称:linode,代码行数:29,代码来源:integration_test.go


示例2: TestAvailKernelsOK

func TestAvailKernelsOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsOK()))
	defer ts.Close()

	kerns, err := c.AvailKernels(nil, nil)
	require.NoError(t, err)
	require.Len(t, kerns, 135)

	var sample Kernel
	var everXen bool
	var everPVOps bool

	for _, k := range kerns {
		if k.IsXen {
			everXen = true
		}
		if k.IsPVOps {
			everPVOps = true
		}
		assert.NotEmpty(t, k.Label, "k.Label")
		assert.NotEmpty(t, k.ID, "k.ID")

		if k.ID == 138 {
			sample = k
		}
	}
	assert.True(t, everXen, "everXen")
	assert.True(t, everPVOps, "everPVOps")

	assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", sample.Label, "sample.Label")
	assert.True(t, sample.IsXen, "sample.IsXen")
	assert.True(t, sample.IsPVOps, "sample.IsPVOps")
	assert.Equal(t, 138, sample.ID, "sample.ID")
}
开发者ID:alexsacr,项目名称:linode,代码行数:34,代码来源:api_utility_test.go


示例3: TestNodeBalancerConfigListOK

func TestNodeBalancerConfigListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockNodeBalancerConfigListOK()))
	defer ts.Close()

	nbconfs, err := c.NodeBalancerConfigList(13128, Int(14591))
	require.NoError(t, err)
	require.Len(t, nbconfs, 1)

	nbc := nbconfs[0]
	assert.Equal(t, "http_cookie", nbc.Stickiness)
	assert.Equal(t, "", nbc.SSLCommonName)
	assert.Equal(t, "/foo", nbc.CheckPath)
	assert.Equal(t, "bar", nbc.CheckBody)
	assert.Equal(t, 30, nbc.CheckInterval)
	assert.Equal(t, "", nbc.SSLFingerprint)
	assert.Equal(t, "roundrobin", nbc.Algorithm)
	assert.Equal(t, 14591, nbc.ID)
	assert.Equal(t, 15, nbc.CheckAttempts)
	assert.Equal(t, 13128, nbc.NodeBalancerID)
	assert.Equal(t, 80, nbc.Port)
	assert.Equal(t, "http", nbc.Check)
	assert.False(t, nbc.CheckPassive)
	assert.Equal(t, "http", nbc.Protocol)
	assert.Equal(t, 29, nbc.CheckTimeout)
}
开发者ID:alexsacr,项目名称:linode,代码行数:25,代码来源:api_nodebalancer_test.go


示例4: TestLinodeConfigList

func TestLinodeConfigList(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeConfigListOK()))
	defer ts.Close()

	confs, err := c.LinodeConfigList(1139016, Int(1855685))
	require.NoError(t, err)
	require.Len(t, confs, 1)

	cfg := confs[0]
	assert.Equal(t, "bar", cfg.RootDeviceCustom)
	assert.Equal(t, "foo", cfg.Comments)
	assert.Equal(t, "test-conf1", cfg.Label)
	assert.Equal(t, 1855685, cfg.ID)
	assert.Equal(t, "3569234,3569220,,,,,,,", cfg.DiskList)
	assert.Equal(t, "default", cfg.RunLevel)
	assert.Equal(t, 1, cfg.RootDeviceNum)
	assert.Equal(t, 800, cfg.RAMLimit)
	assert.Equal(t, "paravirt", cfg.VirtMode)
	assert.Equal(t, 1139016, cfg.LinodeID)
	assert.Equal(t, 138, cfg.KernelID)
	assert.True(t, cfg.DevTmpFSAutomount)
	assert.True(t, cfg.HelperDistro)
	assert.True(t, cfg.HelperDisableUpdateDB)
	assert.True(t, cfg.HelperDepmod)
	assert.True(t, cfg.HelperXen)
	assert.True(t, cfg.RootDeviceRO)
	assert.True(t, cfg.HelperNetwork)
	assert.True(t, cfg.IsRescue)
}
开发者ID:alexsacr,项目名称:linode,代码行数:29,代码来源:api_linode_test.go


示例5: TestStackScriptIntegration

func TestStackScriptIntegration(t *testing.T) {
	c := NewClient(apiKey)

	ssID, err := c.StackScriptCreate("test", "130,", "#! /bin/bash foo", String("foo"),
		Bool(false), String("bar"))
	require.NoError(t, err)
	require.NotEmpty(t, ssID)

	ssList, err := c.StackScriptList(Int(ssID))
	require.NoError(t, err)
	require.Len(t, ssList, 1)

	ss := ssList[0]
	assert.Equal(t, "bar", ss.RevNote)
	assert.Equal(t, "#! /bin/bash foo", ss.Script)
	assert.Equal(t, "130,", ss.DistIDList)
	assert.Equal(t, "foo", ss.Description)
	assert.NotEmpty(t, ss.RevDT)
	assert.Equal(t, "test", ss.Label)
	assert.Equal(t, 0, ss.TotalDeploys)
	assert.NotEmpty(t, ss.LatestRev)
	assert.Equal(t, ssID, ss.ID)
	assert.False(t, ss.IsPublic)
	assert.Equal(t, 0, ss.ActiveDeploys)
	assert.NotEmpty(t, ss.CreateDT)
	assert.NotEmpty(t, ss.UserID)

	err = c.StackScriptUpdate(ssID, String("test-2"), String("quux"), String("129,130"), Bool(true),
		String("baz"), String("#! /bin/bash baz"))
	require.NoError(t, err)

	ssList, err = c.StackScriptList(Int(ssID))
	require.NoError(t, err)
	require.Len(t, ssList, 1)

	ss = ssList[0]
	assert.Equal(t, "baz", ss.RevNote)
	assert.Equal(t, "#! /bin/bash baz", ss.Script)
	assert.Equal(t, "129,130", ss.DistIDList)
	assert.Equal(t, "quux", ss.Description)
	assert.Equal(t, "test-2", ss.Label)
	assert.Equal(t, ssID, ss.ID)
	assert.True(t, ss.IsPublic)

	err = c.StackScriptDelete(ssID)
	require.NoError(t, err)
}
开发者ID:alexsacr,项目名称:linode,代码行数:47,代码来源:integration_test.go


示例6: TestImageListPendingOnlyOK

func TestImageListPendingOnlyOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockImageListPendingOnlyOK()))
	defer ts.Close()

	imgs, err := c.ImageList(Int(402716), Bool(true))
	require.NoError(t, err)
	require.Len(t, imgs, 0)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_image_test.go


示例7: TestAvailKernelsEmpty

func TestAvailKernelsEmpty(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsEmpty()))
	defer ts.Close()

	kerns, err := c.AvailKernels(Int(4389048234), Bool(false))
	require.NoError(t, err)
	require.Len(t, kerns, 0)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_utility_test.go


示例8: TestAvailLinodePlansEmpty

func TestAvailLinodePlansEmpty(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailLinodePlansEmpty()))
	defer ts.Close()

	plans, err := c.AvailLinodePlans(Int(3498230))
	require.NoError(t, err)
	require.Len(t, plans, 0)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_utility_test.go


示例9: TestAvailKernelsSingle

func TestAvailKernelsSingle(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsSingle()))
	defer ts.Close()

	kerns, err := c.AvailKernels(Int(138), Bool(true))
	require.NoError(t, err)
	require.Len(t, kerns, 1)

	k := kerns[0]

	assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", k.Label, "k.Label")
	assert.True(t, k.IsXen, "k.IsXen")
	assert.True(t, k.IsPVOps, "k.IsPVOps")
	assert.Equal(t, 138, k.ID, "k.ID")
}
开发者ID:alexsacr,项目名称:linode,代码行数:15,代码来源:api_utility_test.go


示例10: TestLinodeIPListOK

func TestLinodeIPListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeIPListOK()))
	defer ts.Close()

	IPList, err := c.LinodeIPList(Int(1146420), Int(1))
	require.NoError(t, err)
	require.Len(t, IPList, 1)

	IP := IPList[0]
	assert.Equal(t, 296963, IP.ID)
	assert.Equal(t, "li959-147.members.linode.com", IP.RDNSName)
	assert.Equal(t, 1146420, IP.LinodeID)
	assert.True(t, IP.IsPublic)
	assert.Equal(t, "45.33.5.147", IP.Address)
}
开发者ID:alexsacr,项目名称:linode,代码行数:15,代码来源:api_linode_test.go


示例11: TestAvailDistributionsSingle

func TestAvailDistributionsSingle(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailDistributionsSingle()))
	defer ts.Close()

	dists, err := c.AvailDistributions(Int(130))
	require.NoError(t, err)
	require.Len(t, dists, 1)

	d := dists[0]
	assert.Equal(t, true, d.RequiresPVOps, "d.RequiresPVOps")
	assert.Equal(t, 130, d.ID, "d.ID")
	assert.Equal(t, true, d.Is64Bit, "d.Is64Bit")
	assert.Equal(t, "Debian 7", d.Label, "d.Label")
	assert.Equal(t, 600, d.MinImageSize, "d.MinImageSize")
	assert.Equal(t, "2014-09-24 13:59:32.0", d.CreateDT, "d.CreateDT")
}
开发者ID:alexsacr,项目名称:linode,代码行数:16,代码来源:api_utility_test.go


示例12: TestNodeBalancerListOK

func TestNodeBalancerListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockNodeBalancerListOK()))
	defer ts.Close()

	nbList, err := c.NodeBalancerList(Int(13128))
	require.NoError(t, err)
	require.Len(t, nbList, 1)

	n := nbList[0]
	assert.Equal(t, "nb-198-58-121-23.dallas.nodebalancer.linode.com", n.Hostname)
	assert.Equal(t, "testing", n.Label)
	assert.Equal(t, 5, n.Throttle)
	assert.Equal(t, 2, n.DatacenterID)
	assert.Equal(t, "198.58.121.23", n.IPv4Addr)
	assert.Equal(t, "2600:3c00:1::c63a:7917", n.IPv6Addr)
	assert.Equal(t, 13128, n.ID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:17,代码来源:api_nodebalancer_test.go


示例13: TestNodeBalancerNodeListOK

func TestNodeBalancerNodeListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockNodeBalancerNodeListOK()))
	defer ts.Close()

	nbNodes, err := c.NodeBalancerNodeList(14591, Int(140574))
	require.NoError(t, err)
	require.Len(t, nbNodes, 1)

	node := nbNodes[0]
	assert.Equal(t, 50, node.Weight)
	assert.Equal(t, "192.168.202.68:90", node.Address)
	assert.Equal(t, "test", node.Label)
	assert.Equal(t, 140574, node.ID)
	assert.Equal(t, "accept", node.Mode)
	assert.Equal(t, 14591, node.ConfigID)
	assert.Equal(t, "Unknown", node.Status)
	assert.Equal(t, 13128, node.NodeBalancerID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:18,代码来源:api_nodebalancer_test.go


示例14: TestAvailLinodePlansSingle

func TestAvailLinodePlansSingle(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailLinodePlansSingle()))
	defer ts.Close()

	plans, err := c.AvailLinodePlans(Int(1))
	require.NoError(t, err)
	require.Len(t, plans, 1)

	p := plans[0]

	assert.Equal(t, 1, p.Cores)
	assert.Equal(t, 10.00, p.Price)
	assert.Equal(t, 1024, p.RAM)
	assert.Equal(t, 2000, p.Xfer)
	assert.Equal(t, 1, p.ID)
	assert.Equal(t, "Linode 1024", p.Label)
	assert.Equal(t, 24, p.Disk)
	assert.Equal(t, 0.015, p.Hourly)
}
开发者ID:alexsacr,项目名称:linode,代码行数:19,代码来源:api_utility_test.go


示例15: TestDomainResourceListOK

func TestDomainResourceListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockDomainResourceListOK()))
	defer ts.Close()

	resources, err := c.DomainResourceList(716074, Int(5337468))
	require.NoError(t, err)
	require.Len(t, resources, 1)
	r := resources[0]

	assert.Equal(t, 716074, r.DomainID)
	assert.Equal(t, 15, r.Port)
	assert.Equal(t, 5337468, r.ID)
	assert.Equal(t, "_foo._tcp", r.Name)
	assert.Equal(t, 10, r.Weight)
	assert.Equal(t, 300, r.TTLSec)
	assert.Equal(t, "bar.baz.com", r.Target)
	assert.Equal(t, 5, r.Priority)
	assert.Equal(t, "tcp", r.Protocol)
	assert.Equal(t, "srv", r.Type)
}
开发者ID:alexsacr,项目名称:linode,代码行数:20,代码来源:api_dns_test.go


示例16: TestImageListOK

func TestImageListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockImageListOK()))
	defer ts.Close()

	imgs, err := c.ImageList(Int(402716), Bool(false))
	require.NoError(t, err)
	require.Len(t, imgs, 1)

	i := imgs[0]
	assert.Equal(t, "baz", i.LastUsedDT)
	assert.Equal(t, 600, i.MinSize)
	assert.Equal(t, "foo", i.Description)
	assert.Equal(t, "bar", i.Label)
	assert.Equal(t, "quux", i.Creator)
	assert.Equal(t, "available", i.Status)
	assert.True(t, i.IsPublic)
	assert.Equal(t, "2015-07-07 23:55:59.0", i.CreateDT)
	assert.Equal(t, "manual", i.Type)
	assert.Equal(t, "ext4", i.FSType)
	assert.Equal(t, 402716, i.ID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:21,代码来源:api_image_test.go


示例17: TestStackScriptListOK

func TestStackScriptListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockStackScriptListOK()))
	defer ts.Close()

	ssList, err := c.StackScriptList(Int(12567))
	require.NoError(t, err)
	require.Len(t, ssList, 1)

	ss := ssList[0]
	assert.Equal(t, "bar", ss.RevNote)
	assert.Equal(t, "#! /bin/bash foo", ss.Script)
	assert.Equal(t, "130,", ss.DistIDList)
	assert.Equal(t, "2015-07-08 23:46:50.0", ss.RevDT)
	assert.Equal(t, "test", ss.Label)
	assert.Equal(t, 1, ss.TotalDeploys)
	assert.Equal(t, 60999, ss.LatestRev)
	assert.Equal(t, 12567, ss.ID)
	assert.True(t, ss.IsPublic)
	assert.Equal(t, 2, ss.ActiveDeploys)
	assert.Equal(t, "2015-07-08 23:46:50.0", ss.CreateDT)
	assert.Equal(t, 1337, ss.UserID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:22,代码来源:api_stackscript_test.go


示例18: TestAvailKernelsIntegration

func TestAvailKernelsIntegration(t *testing.T) {
	c := NewClient(apiKey)

	kerns, err := c.AvailKernels(nil, nil)
	require.NoError(t, err)
	require.NotEmpty(t, kerns)

	var everXen bool
	var everPVOps bool

	for _, k := range kerns {
		if k.IsXen {
			everXen = true
		}
		if k.IsPVOps {
			everPVOps = true
		}
		assert.NotEmpty(t, k.Label, "k.Label")
		assert.NotEmpty(t, k.ID, "k.ID")
	}
	assert.True(t, everXen, "everXen")
	assert.True(t, everPVOps, "everPVOps")

	kerns, err = c.AvailKernels(Int(138), Bool(true))
	require.NoError(t, err)
	require.Len(t, kerns, 1)

	k := kerns[0]

	assert.True(t, k.IsXen)
	assert.True(t, k.IsPVOps)
	assert.NotEmpty(t, k.ID)
	assert.NotEmpty(t, k.Label)

	kerns, err = c.AvailKernels(Int(4389048234), Bool(false))
	require.NoError(t, err)
	require.Empty(t, kerns)
}
开发者ID:alexsacr,项目名称:linode,代码行数:38,代码来源:integration_test.go


示例19: TestAvailStackScriptsOK

func TestAvailStackScriptsOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailStackScriptsOK()))
	defer ts.Close()

	scripts, err := c.AvailStackScripts(Int(1), String("bar"), String("baz"))
	require.NoError(t, err)
	require.Len(t, scripts, 1)

	s := scripts[0]
	assert.Equal(t, "Professional Services", s.RevNote)
	assert.Contains(t, s.Script, "#!/bin/bash")
	assert.Equal(t, "127", s.DistIDList)
	assert.Contains(t, s.Description, "cPanel takes an hour to install.")
	assert.Equal(t, "2015-01-07 15:48:57.0", s.RevDT)
	assert.Equal(t, "cPanel", s.Label)
	assert.Equal(t, 207, s.TotalDeploys)
	assert.Equal(t, 53081, s.LatestRev)
	assert.Equal(t, 11078, s.ID)
	assert.True(t, s.IsPublic)
	assert.Equal(t, 125, s.ActiveDeploys)
	assert.Equal(t, "2015-01-07 15:48:57.0", s.CreateDT)
	assert.Equal(t, 307510, s.UserID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:23,代码来源:api_utility_test.go


示例20: TestDomainListOK

func TestDomainListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockDomainListOK()))
	defer ts.Close()

	domains, err := c.DomainList(Int(716074))
	require.NoError(t, err)
	require.Len(t, domains, 1)
	d := domains[0]

	assert.Equal(t, 716074, d.ID)
	assert.Equal(t, "foo", d.Description)
	assert.Equal(t, 300, d.ExpireSec)
	assert.Equal(t, 300, d.RetrySec)
	assert.Equal(t, 1, d.Status)
	assert.Equal(t, "test", d.DisplayGroup)
	assert.Equal(t, "1;2;3;", d.MasterIPs)
	assert.Equal(t, 300, d.RefreshSec)
	assert.Equal(t, "[email protected]", d.SOAEmail)
	assert.Equal(t, 300, d.TTLSec)
	assert.Equal(t, "foo.com", d.Domain)
	assert.Equal(t, "master", d.Type)
	assert.Equal(t, "", d.AXFRIPs)
}
开发者ID:alexsacr,项目名称:linode,代码行数:23,代码来源:api_dns_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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