Skip to content

Commit

Permalink
pr: handle errors in dump flag test
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Raines committed Feb 11, 2021
1 parent b7a3296 commit 2954cde
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cli/ingress-controller/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,24 @@ func TestDumpConfig(t *testing.T) {
tests := []struct {
value string
expectedMode util.ConfigDumpMode
errors bool
}{
{"", util.ConfigDumpModeOff},
{"enabled", util.ConfigDumpModeEnabled},
{"sensitive", util.ConfigDumpModeSensitive},
{"garbagedjgnkdgd", util.ConfigDumpModeOff},
{"", util.ConfigDumpModeOff, false},
{"enabled", util.ConfigDumpModeEnabled, false},
{"sensitive", util.ConfigDumpModeSensitive, false},
{"garbagedjgnkdgd", util.ConfigDumpModeOff, true},
}

for _, test := range tests {
resetForTesting(func() { t.Fatal("bad parse") })
assert := assert.New(t)
os.Setenv("CONTROLLER_DUMP_CONFIG", test.value)
conf, err := parseFlags()
assert.Nil(err, "unexpected error parsing dump config")
if test.errors {
assert.NotNil(err, "error not emitted when expected parsing dump config")
} else {
assert.Nil(err, "unexpected error parsing dump config")
}
assert.Equal(test.expectedMode, conf.DumpConfig)
os.Unsetenv("CONTROLLER_DUMP_CONFIG")
}
Expand Down

0 comments on commit 2954cde

Please sign in to comment.