Skip to content
Merged
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
42 changes: 41 additions & 1 deletion daemon/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"testing"

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

Expand Down Expand Up @@ -53,5 +54,44 @@ func TestGetConflictConfigurations(t *testing.T) {
}

func TestGetUnknownFlags(t *testing.T) {
// TODO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove redundant blank line here @cyrann

flagSet := new(pflag.FlagSet)
flagSet.String("a", "a", "a")
flagSet.Bool("b", false, "b")
flagSet.Int("c", -500, "c")

flagSetNil := new(pflag.FlagSet)

assert := assert.New(t)

fileFlagsKnown := map[string]interface{}{
"a": "a",
"b": true,
}

fileFlagsUnknown := map[string]interface{}{
"c": 100,
"d": "d",
}

fileFlagsNil := map[string]interface{}{}

error := getUnknownFlags(flagSet, fileFlagsKnown)
assert.Equal(error, nil)

error = getUnknownFlags(flagSet, fileFlagsUnknown)
assert.NotNil(error)

error = getUnknownFlags(flagSet, fileFlagsNil)
assert.Equal(error, nil)

error = getUnknownFlags(flagSetNil, fileFlagsUnknown)
assert.NotNil(error)

error = getUnknownFlags(flagSetNil, fileFlagsKnown)
assert.NotNil(error)

error = getUnknownFlags(flagSetNil, fileFlagsNil)
assert.Equal(error, nil)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

}