Skip to content

Commit

Permalink
con
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaRise committed Jul 24, 2018
1 parent 2f0b5cf commit a9a4cb0
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion daemon/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/spf13/pflag"
)

func TestIterateConfig(t *testing.T) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a9a4cb0

Please sign in to comment.