daemon/config: use initialized config in more tests
Makes sure that tests use a config struct that's more representative
to how it's used in the code.
@@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/opts"
units "github.com/docker/go-units"
+ "github.com/imdario/mergo"
"github.com/spf13/pflag"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -112,7 +113,8 @@ func TestDaemonConfigurationMergeShmSize(t *testing.T) {
file := fs.NewFile(t, "docker-config", fs.WithContent(data))
defer file.Remove()
- c := &Config{}
+ c, err := New()
+ assert.NilError(t, err)
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
shmSize := opts.MemBytes(DefaultShmSize)
@@ -156,7 +158,10 @@ func TestUnixValidateConfigurationErrors(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.doc, func(t *testing.T) {
- err := Validate(tc.config)
+ cfg, err := New()
+ assert.NilError(t, err)
+ assert.Check(t, mergo.Merge(cfg, tc.config, mergo.WithOverride))
+ err = Validate(cfg)
assert.ErrorContains(t, err, tc.expectedErr)
})
}
