1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

cmd/dockerd: use initialized config in 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:07:03 +02:00
parent ff1b933d96
commit 2d7d81bc46
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -12,12 +12,13 @@ import (
)
func defaultOptions(t *testing.T, configFile string) *daemonOptions {
opts := newDaemonOptions(&config.Config{})
cfg, err := config.New()
assert.NilError(t, err)
opts := newDaemonOptions(cfg)
opts.flags = &pflag.FlagSet{}
opts.installFlags(opts.flags)
if err := installConfigFlags(opts.daemonConfig, opts.flags); err != nil {
t.Fatal(err)
}
err = installConfigFlags(opts.daemonConfig, opts.flags)
assert.NilError(t, err)
defaultDaemonConfigFile, err := getDefaultDaemonConfigFile()
assert.NilError(t, err)
opts.flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "")