本文整理汇总了Golang中github.com/bryanl/doit/Godeps/_workspace/src/github.com/stretchr/testify/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSSH_Name
func TestSSH_Name(t *testing.T) {
didFetchDroplet := false
client := &godo.Client{
Droplets: &doit.DropletsServiceMock{
ListFn: func(*godo.ListOptions) ([]godo.Droplet, *godo.Response, error) {
didFetchDroplet = true
return testDropletList, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ms := &sshMock{}
c.SSHFn = ms.cmd()
ns := "test"
err := RunSSH(ns, c, ioutil.Discard, []string{testDroplet.Name})
assert.NoError(t, err)
assert.Equal(t, "root", ms.user)
assert.Equal(t, testDroplet.Networks.V4[0].IPAddress, ms.host)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:25,代码来源:ssh_test.go
示例2: TestRecordsUpdate
func TestRecordsUpdate(t *testing.T) {
client := &godo.Client{
Domains: &doit.DomainsServiceMock{
EditRecordFn: func(name string, id int, req *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
expected := &godo.DomainRecordEditRequest{
Type: "A",
Name: "foo.example.com.",
Data: "192.168.1.1",
}
assert.Equal(t, "example.com", name)
assert.Equal(t, 1, id)
assert.Equal(t, expected, req)
return &testRecord, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgRecordID, 1)
c.Set(ns, doit.ArgRecordType, "A")
c.Set(ns, doit.ArgRecordName, "foo.example.com.")
c.Set(ns, doit.ArgRecordData, "192.168.1.1")
err := RunRecordUpdate(ns, c, ioutil.Discard, []string{"example.com"})
assert.NoError(t, err)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:30,代码来源:domains_test.go
示例3: TestKeysUpdateByFingerprint
func TestKeysUpdateByFingerprint(t *testing.T) {
client := &godo.Client{
Keys: &doit.KeysServiceMock{
UpdateByFingerprintFn: func(fingerprint string, req *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error) {
expected := &godo.KeyUpdateRequest{
Name: "the key",
}
assert.Equal(t, req, expected)
assert.Equal(t, fingerprint, "fingerprint")
return &testKey, nil, nil
},
UpdateByIDFn: func(_ int, _ *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error) {
t.Error("should update by fingerprint")
return nil, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgKeyName, "the key")
RunKeyUpdate(ns, c, ioutil.Discard, []string{"fingerprint"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:26,代码来源:sshkeys_test.go
示例4: TestSSH_ID
func TestSSH_ID(t *testing.T) {
didFetchDroplet := false
client := &godo.Client{
Droplets: &doit.DropletsServiceMock{
GetFn: func(id int) (*godo.Droplet, *godo.Response, error) {
assert.Equal(t, id, testDroplet.ID, "droplet ids did not match")
didFetchDroplet = true
return &testDroplet, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ms := &sshMock{}
c.SSHFn = ms.cmd()
ns := "test"
err := RunSSH(ns, c, ioutil.Discard, []string{strconv.Itoa(testDroplet.ID)})
assert.NoError(t, err)
assert.True(t, didFetchDroplet)
assert.True(t, ms.didRun)
assert.Equal(t, "root", ms.user)
assert.Equal(t, testDroplet.Networks.V4[0].IPAddress, ms.host)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:26,代码来源:ssh_test.go
示例5: TestDropletCreate
func TestDropletCreate(t *testing.T) {
client := &godo.Client{
Droplets: &doit.DropletsServiceMock{
CreateFn: func(cr *godo.DropletCreateRequest) (*godo.Droplet, *godo.Response, error) {
expected := &godo.DropletCreateRequest{
Name: "droplet",
Image: godo.DropletCreateImage{Slug: "image"},
Region: "dev0",
Size: "1gb",
UserData: "#cloud-config",
SSHKeys: []godo.DropletCreateSSHKey{},
}
assert.Equal(t, cr, expected, "create requests did not match")
return &testDroplet, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgRegionSlug, "dev0")
c.Set(ns, doit.ArgSizeSlug, "1gb")
c.Set(ns, doit.ArgImage, "image")
c.Set(ns, doit.ArgUserData, "#cloud-config")
err := RunDropletCreate(ns, c, ioutil.Discard, []string{"droplet"})
assert.NoError(t, err)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:31,代码来源:droplets_test.go
示例6: TestSSHPublicKeyImportWithName
func TestSSHPublicKeyImportWithName(t *testing.T) {
pubkey := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn6eZ8ve0ha04rPRZuoPXK1AQ/h21qslWCzoDcOciXn5OcyafkZw+31k/afaBTeW62D8fXd8e/1xWbFfp/2GqmslYpNCTPrtpNhsE8I0yKjJ8FxX9FfsCOu/Sv83dWgSpiT7pNWVKarZjW9KdKKRQljq1i+H5pX3r5Q9I1v+66mYTe7qsKGas9KWy0vkGoNSqmTCl+d+Y0286chtqBqBjSCUCI8oLKPnJB86Lj344tFGmzDIsJKXMVHTL0dF8n3u6iWN4qiRU+JvkoIkI3v0JvyZXxhR2uPIS1yUAY2GC+2O5mfxydJQzBdtag5Uw8Y7H5yYR1gar/h16bAy5XzRvp testkey"
path := filepath.Join(os.TempDir(), "key.pub")
err := ioutil.WriteFile(path, []byte(pubkey), 0600)
assert.NoError(t, err)
defer os.Remove(path)
client := &godo.Client{
Keys: &doit.KeysServiceMock{
CreateFn: func(req *godo.KeyCreateRequest) (*godo.Key, *godo.Response, error) {
expected := &godo.KeyCreateRequest{
Name: "custom",
PublicKey: pubkey,
}
assert.Equal(t, req, expected)
return &testKey, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgKeyPublicKeyFile, path)
RunKeyImport(ns, c, ioutil.Discard, []string{"custom"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:27,代码来源:sshkeys_test.go
示例7: TestDropletNeighbors
func TestDropletNeighbors(t *testing.T) {
didRun := false
client := &godo.Client{
Droplets: &doit.DropletsServiceMock{
NeighborsFn: func(id int) ([]godo.Droplet, *godo.Response, error) {
didRun = true
assert.Equal(t, id, 1)
resp := &godo.Response{
Links: &godo.Links{
Pages: &godo.Pages{},
},
}
return testDropletList, resp, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgDropletID, testDroplet.ID)
err := RunDropletNeighbors(ns, c, ioutil.Discard, []string{})
assert.NoError(t, err)
assert.True(t, didRun)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:27,代码来源:droplets_test.go
示例8: TestLiveCommand_Start
func TestLiveCommand_Start(t *testing.T) {
lc := NewLiveCommand("/bin/ls")
err := lc.Start("/tmp")
assert.NoError(t, err)
assert.Equal(t, []string{"/bin/ls", "/tmp"}, lc.cmd.Args)
err = lc.Stop()
assert.NoError(t, err)
}
开发者ID:alexcb,项目名称:doit,代码行数:10,代码来源:commmand_test.go
示例9: TestFloatingIPActionsGet
func TestFloatingIPActionsGet(t *testing.T) {
client := &godo.Client{
FloatingIPActions: &doit.FloatingIPActionsServiceMock{
GetFn: func(ip string, actionID int) (*godo.Action, *godo.Response, error) {
assert.Equal(t, "127.0.0.1", ip)
assert.Equal(t, 2, actionID)
return &testAction, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgActionID, 2)
RunFloatingIPActionsGet(ns, c, ioutil.Discard, []string{"127.0.0.1"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:19,代码来源:floating_ip_actions_test.go
示例10: TestImageActionsGet
func TestImageActionsGet(t *testing.T) {
client := &godo.Client{
ImageActions: &doit.ImageActionsServiceMock{
GetFn: func(imageID, actionID int) (*godo.Action, *godo.Response, error) {
assert.Equal(t, imageID, 1)
assert.Equal(t, actionID, 2)
return &testAction, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgActionID, 2)
RunImageActionsGet(ns, c, ioutil.Discard, []string{"1"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:19,代码来源:image_actions_test.go
示例11: TestFloatingIPsCreate
func TestFloatingIPsCreate(t *testing.T) {
client := &godo.Client{
FloatingIPs: &doit.FloatingIPsServiceMock{
CreateFn: func(req *godo.FloatingIPCreateRequest) (*godo.FloatingIP, *godo.Response, error) {
assert.Equal(t, "dev0", req.Region)
assert.Equal(t, 1, req.DropletID)
return &testFloatingIP, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgRegionSlug, "dev0")
c.Set(ns, doit.ArgDropletID, 1)
RunFloatingIPCreate(ns, c, ioutil.Discard, []string{})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:19,代码来源:floating_ips_test.go
示例12: TestImagesUpdate
func TestImagesUpdate(t *testing.T) {
client := &godo.Client{
Images: &doit.ImagesServiceMock{
UpdateFn: func(id int, req *godo.ImageUpdateRequest) (*godo.Image, *godo.Response, error) {
expected := &godo.ImageUpdateRequest{Name: "new-name"}
assert.Equal(t, req, expected)
assert.Equal(t, id, testImage.ID)
return &testImage, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgImageName, "new-name")
RunImagesUpdate(ns, c, ioutil.Discard, []string{strconv.Itoa(testImage.ID)})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:20,代码来源:images_test.go
示例13: TestMockCommmand_Run
func TestMockCommmand_Run(t *testing.T) {
mc := NewMockCommand("/bin/ls")
assert.Equal(t, "/bin/ls", mc.path)
runErr := errors.New("an error")
mc.runFn = func() error {
return runErr
}
_, err := mc.Run()
assert.Error(t, err)
}
开发者ID:alexcb,项目名称:doit,代码行数:12,代码来源:commmand_test.go
示例14: TestImageActionsTransfer
func TestImageActionsTransfer(t *testing.T) {
client := &godo.Client{
ImageActions: &doit.ImageActionsServiceMock{
TransferFn: func(imageID int, req *godo.ActionRequest) (*godo.Action, *godo.Response, error) {
assert.Equal(t, imageID, 1)
region := (*req)["region"]
assert.Equal(t, region, "dev0")
return &testAction, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
c.Set(ns, doit.ArgRegionSlug, "dev0")
RunImageActionsTransfer(ns, c, ioutil.Discard, []string{"1"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:21,代码来源:image_actions_test.go
示例15: TestFloatingIPsDelete
func TestFloatingIPsDelete(t *testing.T) {
client := &godo.Client{
FloatingIPs: &doit.FloatingIPsServiceMock{
DeleteFn: func(ip string) (*godo.Response, error) {
assert.Equal(t, "127.0.0.1", ip)
return nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
RunFloatingIPDelete(ns, c, ioutil.Discard, []string{"127.0.0.1"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:16,代码来源:floating_ips_test.go
示例16: TestImagesDelete
func TestImagesDelete(t *testing.T) {
client := &godo.Client{
Images: &doit.ImagesServiceMock{
DeleteFn: func(id int) (*godo.Response, error) {
assert.Equal(t, id, testImage.ID)
return nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
RunImagesDelete(ns, c, ioutil.Discard, []string{strconv.Itoa(testImage.ID)})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:17,代码来源:images_test.go
示例17: TestDropletGet
func TestDropletGet(t *testing.T) {
client := &godo.Client{
Droplets: &doit.DropletsServiceMock{
GetFn: func(id int) (*godo.Droplet, *godo.Response, error) {
assert.Equal(t, id, testDroplet.ID, "droplet ids did not match")
return &testDroplet, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
err := RunDropletGet(ns, c, ioutil.Discard, []string{strconv.Itoa(testDroplet.ID)})
assert.NoError(t, err)
})
}
开发者ID:alexcb,项目名称:doit,代码行数:17,代码来源:droplets_test.go
示例18: Test_extractHostInfo
func Test_extractHostInfo(t *testing.T) {
cases := []struct {
s string
e sshHostInfo
}{
{s: "host", e: sshHostInfo{host: "host"}},
{s: "[email protected]", e: sshHostInfo{user: "root", host: "host"}},
{s: "[email protected]:22", e: sshHostInfo{user: "root", host: "host", port: "22"}},
{s: "host:22", e: sshHostInfo{host: "host", port: "22"}},
{s: "[email protected]", e: sshHostInfo{host: "simple-task-02efb9c4", user: "dokku"}},
}
for _, c := range cases {
i := extractHostInfo(c.s)
assert.Equal(t, c.e, i)
}
}
开发者ID:alexcb,项目名称:doit,代码行数:17,代码来源:ssh_test.go
示例19: TestFloatingIPActionsUnassign
func TestFloatingIPActionsUnassign(t *testing.T) {
client := &godo.Client{
FloatingIPActions: &doit.FloatingIPActionsServiceMock{
UnassignFn: func(ip string) (*godo.Action, *godo.Response, error) {
assert.Equal(t, ip, "127.0.0.1")
return &testAction, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
RunFloatingIPActionsUnassign(ns, c, ioutil.Discard, []string{"127.0.0.1"})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:18,代码来源:floating_ip_actions_test.go
示例20: TestKeysGetByFingerprint
func TestKeysGetByFingerprint(t *testing.T) {
client := &godo.Client{
Keys: &doit.KeysServiceMock{
GetByFingerprintFn: func(fingerprint string) (*godo.Key, *godo.Response, error) {
assert.Equal(t, fingerprint, testKey.Fingerprint)
return &testKey, nil, nil
},
GetByIDFn: func(_ int) (*godo.Key, *godo.Response, error) {
t.Error("should not request by id")
return nil, nil, nil
},
},
}
withTestClient(client, func(c *TestConfig) {
ns := "test"
RunKeyGet(ns, c, ioutil.Discard, []string{testKey.Fingerprint})
})
}
开发者ID:alexcb,项目名称:doit,代码行数:20,代码来源:sshkeys_test.go
注:本文中的github.com/bryanl/doit/Godeps/_workspace/src/github.com/stretchr/testify/assert.Equal函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论