Automated migration using
gty-migrate-from-testify --ignore-build-tags Signed-off-by: Daniel Nephin <dnephin@docker.com> Upstream-commit: 6be0f709830113966f295401327b027ec2f0bbca Component: engine
This commit is contained in:
@@ -6,8 +6,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDaemonParseShmSize(t *testing.T) {
|
||||
@@ -16,7 +17,7 @@ func TestDaemonParseShmSize(t *testing.T) {
|
||||
conf := &config.Config{}
|
||||
installConfigFlags(conf, flags)
|
||||
// By default `--default-shm-size=64M`
|
||||
assert.Equal(t, int64(64*1024*1024), conf.ShmSize.Value())
|
||||
assert.NoError(t, flags.Set("default-shm-size", "128M"))
|
||||
assert.Equal(t, int64(128*1024*1024), conf.ShmSize.Value())
|
||||
assert.Check(t, is.Equal(int64(64*1024*1024), conf.ShmSize.Value()))
|
||||
assert.Check(t, flags.Set("default-shm-size", "128M"))
|
||||
assert.Check(t, is.Equal(int64(128*1024*1024), conf.ShmSize.Value()))
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func defaultOptions(configFile string) *daemonOptions {
|
||||
@@ -27,8 +27,8 @@ func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
|
||||
opts.Debug = true
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
if !loadedConfig.Debug {
|
||||
t.Fatalf("expected debug to be copied from the common flags, got false")
|
||||
}
|
||||
@@ -40,9 +40,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
|
||||
opts.TLS = true
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "/tmp/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("/tmp/ca.pem", loadedConfig.CommonTLSOptions.CAFile))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||
@@ -53,9 +53,9 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||
opts := defaultOptions(configFile)
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("config-file", configFile))
|
||||
assert.NoError(t, flags.Set("label", "l1=bar"))
|
||||
assert.NoError(t, flags.Set("label", "l2=baz"))
|
||||
assert.Check(t, flags.Set("config-file", configFile))
|
||||
assert.Check(t, flags.Set("label", "l1=bar"))
|
||||
assert.Check(t, flags.Set("label", "l2=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
testutil.ErrorContains(t, err, "as a flag and in the configuration file: labels")
|
||||
@@ -69,9 +69,9 @@ func TestLoadDaemonCliWithConflictingNodeGenericResources(t *testing.T) {
|
||||
opts := defaultOptions(configFile)
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("config-file", configFile))
|
||||
assert.NoError(t, flags.Set("node-generic-resource", "r1=bar"))
|
||||
assert.NoError(t, flags.Set("node-generic-resource", "r2=baz"))
|
||||
assert.Check(t, flags.Set("config-file", configFile))
|
||||
assert.Check(t, flags.Set("node-generic-resource", "r1=bar"))
|
||||
assert.Check(t, flags.Set("node-generic-resource", "r2=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
testutil.ErrorContains(t, err, "as a flag and in the configuration file: node-generic-resources")
|
||||
@@ -81,22 +81,22 @@ func TestLoadDaemonCliWithConflictingLabels(t *testing.T) {
|
||||
opts := defaultOptions("")
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("label", "foo=bar"))
|
||||
assert.NoError(t, flags.Set("label", "foo=baz"))
|
||||
assert.Check(t, flags.Set("label", "foo=bar"))
|
||||
assert.Check(t, flags.Set("label", "foo=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
assert.EqualError(t, err, "conflict labels for foo=baz and foo=bar")
|
||||
assert.Check(t, is.Error(err, "conflict labels for foo=baz and foo=bar"))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliWithDuplicateLabels(t *testing.T) {
|
||||
opts := defaultOptions("")
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("label", "foo=the-same"))
|
||||
assert.NoError(t, flags.Set("label", "foo=the-same"))
|
||||
assert.Check(t, flags.Set("label", "foo=the-same"))
|
||||
assert.Check(t, flags.Set("label", "foo=the-same"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||
@@ -107,9 +107,9 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, loadedConfig.TLS, true)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal(loadedConfig.TLS, true))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||
@@ -120,9 +120,9 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.True(t, loadedConfig.TLS)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, loadedConfig.TLS)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||
@@ -133,9 +133,9 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.False(t, loadedConfig.TLS)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, !loadedConfig.TLS)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||
@@ -144,10 +144,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "warn", loadedConfig.LogLevel)
|
||||
assert.Equal(t, logrus.WarnLevel, logrus.GetLevel())
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("warn", loadedConfig.LogLevel))
|
||||
assert.Check(t, is.Equal(logrus.WarnLevel, logrus.GetLevel()))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||
@@ -157,10 +157,10 @@ func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "/etc/certs/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
|
||||
assert.Equal(t, "syslog", loadedConfig.LogConfig.Type)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("/etc/certs/ca.pem", loadedConfig.CommonTLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal("syslog", loadedConfig.LogConfig.Type))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
@@ -174,10 +174,10 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.Len(t, loadedConfig.AllowNondistributableArtifacts, 1)
|
||||
assert.Len(t, loadedConfig.Mirrors, 1)
|
||||
assert.Len(t, loadedConfig.InsecureRegistries, 1)
|
||||
assert.Check(t, is.Len(loadedConfig.AllowNondistributableArtifacts, 1))
|
||||
assert.Check(t, is.Len(loadedConfig.Mirrors, 1))
|
||||
assert.Check(t, is.Len(loadedConfig.InsecureRegistries, 1))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||
@@ -19,17 +19,17 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
opts.Debug = true
|
||||
opts.LogLevel = "info"
|
||||
assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
|
||||
assert.Check(t, opts.flags.Set("selinux-enabled", "true"))
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.True(t, loadedConfig.Debug)
|
||||
assert.Equal(t, "info", loadedConfig.LogLevel)
|
||||
assert.True(t, loadedConfig.EnableSelinuxSupport)
|
||||
assert.Equal(t, "json-file", loadedConfig.LogConfig.Type)
|
||||
assert.Equal(t, "1k", loadedConfig.LogConfig.Config["max-size"])
|
||||
assert.Check(t, loadedConfig.Debug)
|
||||
assert.Check(t, is.Equal("info", loadedConfig.LogLevel))
|
||||
assert.Check(t, loadedConfig.EnableSelinuxSupport)
|
||||
assert.Check(t, is.Equal("json-file", loadedConfig.LogConfig.Type))
|
||||
assert.Check(t, is.Equal("1k", loadedConfig.LogConfig.Config["max-size"]))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
||||
@@ -39,11 +39,11 @@ func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.Equal(t, "127.0.0.2", loadedConfig.IP)
|
||||
assert.Equal(t, "127.0.0.1", loadedConfig.DefaultIP.String())
|
||||
assert.Check(t, is.Equal("127.0.0.2", loadedConfig.IP))
|
||||
assert.Check(t, is.Equal("127.0.0.1", loadedConfig.DefaultIP.String()))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||
@@ -56,14 +56,14 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NotNil(t, loadedConfig.ClusterOpts)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, loadedConfig.ClusterOpts != nil)
|
||||
|
||||
expectedPath := "/var/lib/docker/discovery_certs/ca.pem"
|
||||
assert.Equal(t, expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"])
|
||||
assert.NotNil(t, loadedConfig.LogConfig.Config)
|
||||
assert.Equal(t, "test", loadedConfig.LogConfig.Config["tag"])
|
||||
assert.Check(t, is.Equal(expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"]))
|
||||
assert.Check(t, loadedConfig.LogConfig.Config != nil)
|
||||
assert.Check(t, is.Equal("test", loadedConfig.LogConfig.Config["tag"]))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||
@@ -73,17 +73,17 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.False(t, loadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, !loadedConfig.EnableUserlandProxy)
|
||||
|
||||
// make sure reloading doesn't generate configuration
|
||||
// conflicts after normalizing boolean values.
|
||||
reload := func(reloadedConfig *config.Config) {
|
||||
assert.False(t, reloadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, !reloadedConfig.EnableUserlandProxy)
|
||||
}
|
||||
assert.NoError(t, config.Reload(opts.configFile, opts.flags, reload))
|
||||
assert.Check(t, config.Reload(opts.configFile, opts.flags, reload))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
@@ -92,8 +92,8 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.True(t, loadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, loadedConfig.EnableUserlandProxy)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ import (
|
||||
|
||||
cliconfig "github.com/docker/docker/cli/config"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCommonOptionsInstallFlags(t *testing.T) {
|
||||
@@ -20,10 +21,10 @@ func TestCommonOptionsInstallFlags(t *testing.T) {
|
||||
"--tlscert=\"/foo/cert\"",
|
||||
"--tlskey=\"/foo/key\"",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "/foo/cafile", opts.TLSOptions.CAFile)
|
||||
assert.Equal(t, "/foo/cert", opts.TLSOptions.CertFile)
|
||||
assert.Equal(t, opts.TLSOptions.KeyFile, "/foo/key")
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("/foo/cafile", opts.TLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal("/foo/cert", opts.TLSOptions.CertFile))
|
||||
assert.Check(t, is.Equal(opts.TLSOptions.KeyFile, "/foo/key"))
|
||||
}
|
||||
|
||||
func defaultPath(filename string) string {
|
||||
@@ -36,8 +37,8 @@ func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
|
||||
opts.InstallFlags(flags)
|
||||
|
||||
err := flags.Parse([]string{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, defaultPath("ca.pem"), opts.TLSOptions.CAFile)
|
||||
assert.Equal(t, defaultPath("cert.pem"), opts.TLSOptions.CertFile)
|
||||
assert.Equal(t, defaultPath("key.pem"), opts.TLSOptions.KeyFile)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(defaultPath("ca.pem"), opts.TLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal(defaultPath("cert.pem"), opts.TLSOptions.CertFile))
|
||||
assert.Check(t, is.Equal(defaultPath("key.pem"), opts.TLSOptions.KeyFile))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user