Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1759 baiji-group=264-3 #1862

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions daemon/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package config

import (
"testing"

"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
"testing"
"errors"
)

func TestIterateConfig(t *testing.T) {
Expand Down Expand Up @@ -49,7 +50,26 @@ func TestConfigValidate(t *testing.T) {
}

func TestGetConflictConfigurations(t *testing.T) {
// TODO
assert := assert.New(t)

fileFlags := map[string]interface{}{
"flag1": "1",
"flag2": "2",
}

flagSet := pflag.NewFlagSet("FlagConfig", pflag.ContinueOnError)
flagSet.String("flag1", "1", "flag1")
flagSet.String("flag2", "2", "flag2")
flagSet.String("flag3", "3", "flag3")
flagSet.IntSlice("slice", []int{1, 2, 3}, "slice data")

assert.Equal(nil, getConflictConfigurations(flagSet, fileFlags))

flagSet.Set("flag1", "2")
assert.Equal(getConflictConfigurations(flagSet, fileFlags), errors.New("found conflict flags in command line and config file: from flag: 2 and from config file: 1"))

flagSet.Set("flag2", "1")
assert.Equal(getConflictConfigurations(flagSet, fileFlags), errors.New("found conflict flags in command line and config file: from flag: 2 and from config file: 1, from flag: 1 and from config file: 2"))
}

func TestGetUnknownFlags(t *testing.T) {
Expand Down