mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/config: improve some tests
- TestReloadWithDuplicateLabels() also check value - TestReloadDefaultConfigNotExist, TestReloadBadDefaultConfig, TestReloadWithConflictingLabels: verify that config is not reloaded. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
f8231c62f4
commit
9b39cab510
1 changed files with 17 additions and 4 deletions
|
@ -495,10 +495,10 @@ func TestReloadSetConfigFileNotExist(t *testing.T) {
|
||||||
// doesn't exist the daemon still will be reloaded.
|
// doesn't exist the daemon still will be reloaded.
|
||||||
func TestReloadDefaultConfigNotExist(t *testing.T) {
|
func TestReloadDefaultConfigNotExist(t *testing.T) {
|
||||||
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
|
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
|
||||||
reloaded := false
|
|
||||||
defaultConfigFile := "/tmp/blabla/not/exists/daemon.json"
|
defaultConfigFile := "/tmp/blabla/not/exists/daemon.json"
|
||||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
flags.String("config-file", defaultConfigFile, "")
|
flags.String("config-file", defaultConfigFile, "")
|
||||||
|
reloaded := false
|
||||||
err := Reload(defaultConfigFile, flags, func(c *Config) {
|
err := Reload(defaultConfigFile, flags, func(c *Config) {
|
||||||
reloaded = true
|
reloaded = true
|
||||||
})
|
})
|
||||||
|
@ -520,8 +520,12 @@ func TestReloadBadDefaultConfig(t *testing.T) {
|
||||||
|
|
||||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
flags.String("config-file", configFile, "")
|
flags.String("config-file", configFile, "")
|
||||||
err = Reload(configFile, flags, func(c *Config) {})
|
reloaded := false
|
||||||
|
err = Reload(configFile, flags, func(c *Config) {
|
||||||
|
reloaded = true
|
||||||
|
})
|
||||||
assert.Check(t, is.ErrorContains(err, "unable to configure the Docker daemon with file"))
|
assert.Check(t, is.ErrorContains(err, "unable to configure the Docker daemon with file"))
|
||||||
|
assert.Check(t, reloaded == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReloadWithConflictingLabels(t *testing.T) {
|
func TestReloadWithConflictingLabels(t *testing.T) {
|
||||||
|
@ -533,8 +537,12 @@ func TestReloadWithConflictingLabels(t *testing.T) {
|
||||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
flags.String("config-file", configFile, "")
|
flags.String("config-file", configFile, "")
|
||||||
flags.StringSlice("labels", lbls, "")
|
flags.StringSlice("labels", lbls, "")
|
||||||
err := Reload(configFile, flags, func(c *Config) {})
|
reloaded := false
|
||||||
|
err := Reload(configFile, flags, func(c *Config) {
|
||||||
|
reloaded = true
|
||||||
|
})
|
||||||
assert.Check(t, is.ErrorContains(err, "conflict labels for foo=baz and foo=bar"))
|
assert.Check(t, is.ErrorContains(err, "conflict labels for foo=baz and foo=bar"))
|
||||||
|
assert.Check(t, reloaded == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReloadWithDuplicateLabels(t *testing.T) {
|
func TestReloadWithDuplicateLabels(t *testing.T) {
|
||||||
|
@ -546,8 +554,13 @@ func TestReloadWithDuplicateLabels(t *testing.T) {
|
||||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
flags.String("config-file", configFile, "")
|
flags.String("config-file", configFile, "")
|
||||||
flags.StringSlice("labels", lbls, "")
|
flags.StringSlice("labels", lbls, "")
|
||||||
err := Reload(configFile, flags, func(c *Config) {})
|
reloaded := false
|
||||||
|
err := Reload(configFile, flags, func(c *Config) {
|
||||||
|
reloaded = true
|
||||||
|
assert.Check(t, is.DeepEqual(c.Labels, []string{"foo=the-same"}))
|
||||||
|
})
|
||||||
assert.Check(t, err)
|
assert.Check(t, err)
|
||||||
|
assert.Check(t, reloaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMaskURLCredentials(t *testing.T) {
|
func TestMaskURLCredentials(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue