test: add ut
This commit is contained in:
parent
22ef776ccd
commit
de0393ac55
@ -301,3 +301,49 @@ func TestSetKeyValueInMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValidateOnDeleteValue(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
desc string
|
||||||
|
onDelete string
|
||||||
|
expected error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "empty value",
|
||||||
|
onDelete: "",
|
||||||
|
expected: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "delete value",
|
||||||
|
onDelete: "delete",
|
||||||
|
expected: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "retain value",
|
||||||
|
onDelete: "retain",
|
||||||
|
expected: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "Retain value",
|
||||||
|
onDelete: "Retain",
|
||||||
|
expected: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "Delete value",
|
||||||
|
onDelete: "Delete",
|
||||||
|
expected: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "invalid value",
|
||||||
|
onDelete: "invalid",
|
||||||
|
expected: fmt.Errorf("invalid value %s for OnDelete, supported values are %v", "invalid", supportedOnDeleteValues),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
result := validateOnDeleteValue(test.onDelete)
|
||||||
|
if !reflect.DeepEqual(result, test.expected) {
|
||||||
|
t.Errorf("test[%s]: unexpected output: %v, expected result: %v", test.desc, result, test.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user