From 5cfcd88d57438a18dadca769f3cb286b327c797f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 4 Apr 2022 14:56:48 +0200 Subject: [PATCH] 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 --- daemon/config/config_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/config/config_test.go b/daemon/config/config_test.go index fee8f6f004..73539ad266 100644 --- a/daemon/config/config_test.go +++ b/daemon/config/config_test.go @@ -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)