diff --git a/daemon/config/config_test.go b/daemon/config/config_test.go index ecaa6389a..4e98a57a7 100644 --- a/daemon/config/config_test.go +++ b/daemon/config/config_test.go @@ -4,6 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" + + "github.com/spf13/pflag" ) func TestIterateConfig(t *testing.T) { @@ -49,7 +51,33 @@ func TestConfigValidate(t *testing.T) { } func TestGetConflictConfigurations(t *testing.T) { - // TODO + assert := assert.New(t) + + fileflags := map[string]interface{}{ + "a": "a1", + "b": []string{"b1", "b2"}, + } + + flags := pflag.NewFlagSet("cmflags", pflag.ContinueOnError) + + // Test No Flags + assert.Equal(nil, getConflictConfigurations(flags, fileflags)) + + flags.String("c", "c1", "c") + // Test No Conflicts + flags.Parse([]string{"--c=c1"}) + assert.Equal(nil, getConflictConfigurations(flags, fileflags)) + + // Test Ignore Conflict of Type "Slice" + flags.StringSlice("b", []string{"b1", "b2"}, "b") + flags.Parse([]string{"--b=b1,b2"}) + assert.Equal(nil, getConflictConfigurations(flags, fileflags)) + + // Test Conflict + flags.String("a", "a1", "a") + flags.Parse([]string{"--a=a1"}) + assert.Equal("found conflict flags in command line and config file: from flag: a1 and from config file: a1", + getConflictConfigurations(flags, fileflags).Error()) } func TestGetUnknownFlags(t *testing.T) {