本文整理汇总了Golang中github.com/alexsacr/linode/_third_party/testify/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAvailDatacentersIntegration
func TestAvailDatacentersIntegration(t *testing.T) {
c := NewClient(apiKey)
datacenters, err := c.AvailDatacenters()
require.NoError(t, err)
require.NotEmpty(t, datacenters)
// Test subset
var foundDallas bool
var foundFremont bool
for _, dc := range datacenters {
switch dc.ID {
case 2:
assert.Equal(t, "Dallas, TX, USA", dc.Location, "dc.Location")
assert.Equal(t, "dallas", dc.Abbr, "dc.Abbr")
foundDallas = true
case 3:
assert.Equal(t, "Fremont, CA, USA", dc.Location, "dc.Location")
assert.Equal(t, "fremont", dc.Abbr, "dc.Abbr")
foundFremont = true
}
}
assert.True(t, foundDallas, "Dallas not returned.")
assert.True(t, foundFremont, "Fremont not returned.")
}
开发者ID:alexsacr,项目名称:linode,代码行数:27,代码来源: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: TestLinodeIPAddPrivateOK
func TestLinodeIPAddPrivateOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeIPAddPrivateOK()))
defer ts.Close()
id, addr, err := c.LinodeIPAddPrivate(1146420)
require.NoError(t, err)
assert.Equal(t, 374332, id)
assert.Equal(t, "192.168.199.65", addr)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go
示例4: TestLinodeDiskDuplicateOK
func TestLinodeDiskDuplicateOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskDuplicateOK()))
defer ts.Close()
jobID, dupeDiskID, err := c.LinodeDiskDuplicate(1139016, 3569220)
require.NoError(t, err)
assert.Equal(t, 25090699, jobID)
assert.Equal(t, 3569577, dupeDiskID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go
示例5: TestLinodeDiskCreateOK
func TestLinodeDiskCreateOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskCreateOK()))
defer ts.Close()
jobID, diskID, err := c.LinodeDiskCreate(1139016, "test-swap", "swap", 256)
require.NoError(t, err)
assert.Equal(t, 3568984, diskID)
assert.Equal(t, 25087627, jobID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go
示例6: TestAccountEstimateInvoiceOK
func TestAccountEstimateInvoiceOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockAccountEstimateInvoiceOK()))
defer ts.Close()
inv, err := c.AccountEstimateInvoice("linode_new", Int(1), Int(1), Int(1))
require.NoError(t, err)
assert.Equal(t, "2015-07-31 23:59:59", inv.InvoiceTo)
assert.Equal(t, 8.07, inv.Price)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_account_test.go
示例7: TestLinodeDiskCreateFromImageOK
func TestLinodeDiskCreateFromImageOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskCreateFromImageOK()))
defer ts.Close()
jobID, imgDiskID, err := c.LinodeDiskCreateFromImage(396235, 1139016, "test-image", Int(800),
String(rootPass), String(rootSSHKey))
require.NoError(t, err)
assert.Equal(t, 25090431, jobID)
assert.Equal(t, 3569532, imgDiskID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:10,代码来源:api_linode_test.go
示例8: TestLinodeDiskImagizeOK
func TestLinodeDiskImagizeOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskImagizeOK()))
defer ts.Close()
jobID, imgID, err := c.LinodeDiskImagize(1139016, 3569234, String("test-image desc"),
String("test-image label"))
require.NoError(t, err)
assert.Equal(t, 25090408, jobID)
assert.Equal(t, 396235, imgID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:11,代码来源:api_linode_test.go
示例9: 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
示例10: 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
示例11: 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
示例12: newMockAPIServer
func newMockAPIServer(t *testing.T, responses []mockAPIResponse) *httptest.Server {
var reqCount int
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if len(responses) < reqCount {
msg := fmt.Sprintf("Request count: %d len(responses): %d", reqCount+1, len(responses))
require.FailNow(t, msg)
}
resp := responses[reqCount]
action := r.FormValue("api_action")
require.NotEmpty(t, action, fmt.Sprintf("%d", reqCount+1))
require.Equal(t, resp.action, action, fmt.Sprintf("%d", reqCount+1))
for k, v := range resp.params {
assert.Equal(t, v, r.FormValue(k), fmt.Sprintf("params: %s - %d", k, reqCount+1))
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_, _ = w.Write([]byte(resp.output()))
reqCount++
}))
return ts
}
开发者ID:alexsacr,项目名称:linode,代码行数:29,代码来源:mocks_test.go
示例13: TestAvailDatacentersOK
func TestAvailDatacentersOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockAvailDatacentersOK()))
defer ts.Close()
datacenters, err := c.AvailDatacenters()
require.NoError(t, err)
require.NotEmpty(t, datacenters)
expected := []Datacenter{
{
Location: "Dallas, TX, USA",
ID: 2,
Abbr: "dallas",
},
{
Location: "Fremont, CA, USA",
ID: 3,
Abbr: "fremont",
},
{
Location: "Atlanta, GA, USA",
ID: 4,
Abbr: "atlanta",
},
{
Location: "Newark, NJ, USA",
ID: 6,
Abbr: "newark",
},
{
Location: "London, England, UK",
ID: 7,
Abbr: "london",
},
{
Location: "Tokyo, JP",
ID: 8,
Abbr: "tokyo",
},
{
Location: "Singapore, SG",
ID: 9,
Abbr: "singapore",
},
}
for i, eDC := range expected {
for _, aDC := range datacenters {
if reflect.DeepEqual(aDC, eDC) {
expected[i] = Datacenter{}
break
}
}
}
for _, dc := range expected {
assert.Equal(t, Datacenter{}, dc, fmt.Sprintf("%+v not returned.", dc))
}
}
开发者ID:alexsacr,项目名称:linode,代码行数:59,代码来源:api_utility_test.go
示例14: TestLinodeShutdownOK
func TestLinodeShutdownOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeShutdownOK()))
defer ts.Close()
jobID, err := c.LinodeShutdown(1146420)
require.NoError(t, err)
assert.Equal(t, 25167147, jobID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_linode_test.go
示例15: TestLinodeRebootOK
func TestLinodeRebootOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeRebootOK()))
defer ts.Close()
jobID, err := c.LinodeReboot(1146420, Int(1862370))
require.NoError(t, err)
assert.Equal(t, jobID, 25167140)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_linode_test.go
示例16: TestLinodeDiskResizeOK
func TestLinodeDiskResizeOK(t *testing.T) {
c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskResizeOK()))
defer ts.Close()
jobID, err := c.LinodeDiskResize(1139016, 3569577, 512)
require.NoError(t, err)
assert.Equal(t, 25090703, jobID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_linode_test.go
示例17: 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
示例18: 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
示例19: TestAvailDistributionsIntegration
func TestAvailDistributionsIntegration(t *testing.T) {
c := NewClient(apiKey)
dists, err := c.AvailDistributions(nil)
require.NoError(t, err)
require.NotEmpty(t, dists)
testDistsNotEmpty(t, dists)
dists, err = c.AvailDistributions(Int(130))
assert.NoError(t, err)
assert.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")
dists, err = c.AvailDistributions(Int(38201938))
assert.NoError(t, err)
assert.Empty(t, dists)
}
开发者ID:alexsacr,项目名称:linode,代码行数:25,代码来源:integration_test.go
示例20: 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
注:本文中的github.com/alexsacr/linode/_third_party/testify/assert.Equal函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论