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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-08-17 14:31:25 +02:00
parent 2d7d81bc46
commit 327c8fc52f
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -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)
})
}