本文整理汇总了Golang中github.com/docker/docker/pkg/testutil/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDurationOptSetAndValue
func TestDurationOptSetAndValue(t *testing.T) {
var duration DurationOpt
assert.NilError(t, duration.Set("300s"))
assert.Equal(t, *duration.Value(), time.Duration(300*10e8))
assert.NilError(t, duration.Set("-300s"))
assert.Equal(t, *duration.Value(), time.Duration(-300*10e8))
}
示例2: TestUpdateSecretUpdateInPlace
// TestUpdateSecretUpdateInPlace tests the ability to update the "target" of an secret with "docker service update"
// by combining "--secret-rm" and "--secret-add" for the same secret.
func TestUpdateSecretUpdateInPlace(t *testing.T) {
apiClient := secretAPIClientMock{
listResult: []swarm.Secret{
{
ID: "tn9qiblgnuuut11eufquw5dev",
Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "foo"}},
},
},
}
flags := newUpdateCommand(nil).Flags()
flags.Set("secret-add", "source=foo,target=foo2")
flags.Set("secret-rm", "foo")
secrets := []*swarm.SecretReference{
{
File: &swarm.SecretReferenceFileTarget{
Name: "foo",
UID: "0",
GID: "0",
Mode: 292,
},
SecretID: "tn9qiblgnuuut11eufquw5dev",
SecretName: "foo",
},
}
updatedSecrets, err := getUpdatedSecrets(apiClient, flags, secrets)
assert.Equal(t, err, nil)
assert.Equal(t, len(updatedSecrets), 1)
assert.Equal(t, updatedSecrets[0].SecretID, "tn9qiblgnuuut11eufquw5dev")
assert.Equal(t, updatedSecrets[0].SecretName, "foo")
assert.Equal(t, updatedSecrets[0].File.Name, "foo2")
}
示例3: TestNodeMetastate_FromBytes
// Check the deserialization of the meta stats structure
func TestNodeMetastate_FromBytes(t *testing.T) {
metastate := NewNodeMetastate(0)
// Serialize into bytes array
bytes, err := metastate.Bytes()
assert.NilError(t, err)
if bytes == nil {
t.Fatal("Was not able to serialize meta state into byte array.")
}
// Deserialize back and check, that state still have same
// height value
state, err := FromBytes(bytes)
assert.NilError(t, err)
assert.Equal(t, state.Height(), uint64(0))
// Update state to the new height and serialize it again
state.Update(17)
bytes, err = state.Bytes()
assert.NilError(t, err)
if bytes == nil {
t.Fatal("Was not able to serialize meta state into byte array.")
}
// Restore state from byte array and validate
// that stored height is still the same
updatedState, err := FromBytes(bytes)
assert.NilError(t, err)
assert.Equal(t, updatedState.Height(), uint64(17))
}
示例4: TestIsReadOnly
func TestIsReadOnly(t *testing.T) {
assert.Equal(t, isReadOnly([]string{"foo", "bar", "ro"}), true)
assert.Equal(t, isReadOnly([]string{"ro"}), true)
assert.Equal(t, isReadOnly([]string{}), false)
assert.Equal(t, isReadOnly([]string{"foo", "rw"}), false)
assert.Equal(t, isReadOnly([]string{"foo"}), false)
}
示例5: TestExternalCAOptionMultiple
func TestExternalCAOptionMultiple(t *testing.T) {
opt := &ExternalCAOption{}
assert.NilError(t, opt.Set("protocol=cfssl,url=https://example.com"))
assert.NilError(t, opt.Set("protocol=CFSSL,url=anything"))
assert.Equal(t, len(opt.Value()), 2)
assert.Equal(t, opt.String(), "cfssl: https://example.com, cfssl: anything")
}
示例6: TestQuotedStringSetWithQuotes
func TestQuotedStringSetWithQuotes(t *testing.T) {
value := ""
qs := NewQuotedString(&value)
assert.NilError(t, qs.Set("\"something\""))
assert.Equal(t, qs.String(), "something")
assert.Equal(t, value, "something")
}
示例7: TestUint64OptString
func TestUint64OptString(t *testing.T) {
value := uint64(2345678)
opt := Uint64Opt{value: &value}
assert.Equal(t, opt.String(), "2345678")
opt = Uint64Opt{}
assert.Equal(t, opt.String(), "none")
}
示例8: TestBuildContainerListOptions
func TestBuildContainerListOptions(t *testing.T) {
filters := opts.NewFilterOpt()
assert.NilError(t, filters.Set("foo=bar"))
assert.NilError(t, filters.Set("baz=foo"))
contexts := []struct {
psOpts *psOptions
expectedAll bool
expectedSize bool
expectedLimit int
expectedFilters map[string]string
}{
{
psOpts: &psOptions{
all: true,
size: true,
last: 5,
filter: filters,
},
expectedAll: true,
expectedSize: true,
expectedLimit: 5,
expectedFilters: map[string]string{
"foo": "bar",
"baz": "foo",
},
},
{
psOpts: &psOptions{
all: true,
size: true,
last: -1,
nLatest: true,
},
expectedAll: true,
expectedSize: true,
expectedLimit: 1,
expectedFilters: make(map[string]string),
},
}
for _, c := range contexts {
options, err := buildContainerListOptions(c.psOpts)
assert.NilError(t, err)
assert.Equal(t, c.expectedAll, options.All)
assert.Equal(t, c.expectedSize, options.Size)
assert.Equal(t, c.expectedLimit, options.Limit)
assert.Equal(t, options.Filter.Len(), len(c.expectedFilters))
for k, v := range c.expectedFilters {
f := options.Filter
if !f.ExactMatch(k, v) {
t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k))
}
}
}
}
示例9: TestLoadDaemonCliConfigWithLogLevel
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
tempFile := tempfile.NewTempFile(t, "config", `{"log-level": "warn"}`)
defer tempFile.Remove()
opts := defaultOptions(tempFile.Name())
loadedConfig, err := loadDaemonCliConfig(opts)
assert.NilError(t, err)
assert.NotNil(t, loadedConfig)
assert.Equal(t, loadedConfig.LogLevel, "warn")
assert.Equal(t, logrus.GetLevel(), logrus.WarnLevel)
}
示例10: TestClientDebugEnabled
func TestClientDebugEnabled(t *testing.T) {
defer debug.Disable()
cmd := newDockerCommand(&command.DockerCli{})
cmd.Flags().Set("debug", "true")
err := cmd.PersistentPreRunE(cmd, []string{})
assert.NilError(t, err)
assert.Equal(t, os.Getenv("DEBUG"), "1")
assert.Equal(t, logrus.GetLevel(), logrus.DebugLevel)
}
示例11: TestCommonOptionsInstallFlagsWithDefaults
func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
flags := pflag.NewFlagSet("testing", pflag.ContinueOnError)
opts := NewCommonOptions()
opts.InstallFlags(flags)
err := flags.Parse([]string{})
assert.NilError(t, err)
assert.Equal(t, opts.TLSOptions.CAFile, defaultPath("ca.pem"))
assert.Equal(t, opts.TLSOptions.CertFile, defaultPath("cert.pem"))
assert.Equal(t, opts.TLSOptions.KeyFile, defaultPath("key.pem"))
}
示例12: TestUpdateEnvironmentWithDuplicateKeys
func TestUpdateEnvironmentWithDuplicateKeys(t *testing.T) {
// Test case for #25404
flags := newUpdateCommand(nil).Flags()
flags.Set("env-add", "A=b")
envs := []string{"A=c"}
updateEnvironment(flags, &envs)
assert.Equal(t, len(envs), 1)
assert.Equal(t, envs[0], "A=b")
}
示例13: TestUpdateEnvironment
func TestUpdateEnvironment(t *testing.T) {
flags := newUpdateCommand(nil).Flags()
flags.Set("env-add", "toadd=newenv")
flags.Set("env-rm", "toremove")
envs := []string{"toremove=theenvtoremove", "tokeep=value"}
updateEnvironment(flags, &envs)
assert.Equal(t, len(envs), 2)
assert.Equal(t, envs[0], "tokeep=value")
assert.Equal(t, envs[1], "toadd=newenv")
}
示例14: TestSecretOptionsSourceTarget
func TestSecretOptionsSourceTarget(t *testing.T) {
var opt SecretOpt
testCase := "source=foo,target=testing"
assert.NilError(t, opt.Set(testCase))
reqs := opt.Value()
assert.Equal(t, len(reqs), 1)
req := reqs[0]
assert.Equal(t, req.Source, "foo")
assert.Equal(t, req.Target, "testing")
}
示例15: TestMountOptSetNoError
func TestMountOptSetNoError(t *testing.T) {
var mount MountOpt
assert.NilError(t, mount.Set("type=bind,target=/target,source=/foo"))
mounts := mount.Value()
assert.Equal(t, len(mounts), 1)
assert.Equal(t, mounts[0], swarm.Mount{
Type: swarm.MountType("BIND"),
Source: "/foo",
Target: "/target",
})
}