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

daemon/config: fix TestReloadDefaultConfigNotExist if file exists

The TestReloadDefaultConfigNotExist() test assumed it was running in a clean
environment, in which the `/etc/docker/daemon.json` file doesn't exist, and
would fail if that was not the case.

This patch updates the test to override the default location to a a non-existing
path, to allow running the test in an environment where `/etc/docker/daemon.json`
is present.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-04-04 14:56:48 +02:00
parent 83970db5ef
commit 5cfcd88d57
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -446,10 +446,10 @@ func TestReloadSetConfigFileNotExist(t *testing.T) {
func TestReloadDefaultConfigNotExist(t *testing.T) {
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
reloaded := false
configFile := "/etc/docker/daemon.json"
defaultConfigFile := "/tmp/blabla/not/exists/daemon.json"
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
flags.String("config-file", configFile, "")
err := Reload(configFile, flags, func(c *Config) {
flags.String("config-file", defaultConfigFile, "")
err := Reload(defaultConfigFile, flags, func(c *Config) {
reloaded = true
})
assert.Check(t, err)