Tested FlagsWithParams.GetBool

This commit is contained in:
adragusin
2019-11-26 12:46:32 +02:00
parent 1e79739911
commit 0c287d09df
6 changed files with 43 additions and 1 deletions

View File

@@ -213,3 +213,27 @@ func TestFlagsToSlice(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", sls, flgSls)
}
}
func TestFlagsWithParamsGetBool(t *testing.T) {
flagsWithParams := &FlagsWithParams{
"test": []string{"string1", "string2"},
"test2": []string{"true", "string2"},
"empty": []string{},
}
key := "notpresent"
if rcv := flagsWithParams.GetBool(key); rcv != false {
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
}
key = "empty"
if rcv := flagsWithParams.GetBool(key); rcv != false {
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
}
key = "test"
if rcv := flagsWithParams.GetBool(key); rcv != false {
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
}
key = "test2"
if rcv := flagsWithParams.GetBool(key); rcv != true {
t.Errorf("Expecting: true, received: %+v", ToJSON(rcv))
}
}