mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-06 18:02:06 +02:00
add unit test and documentation for finalizers (#2509)
* add unit test and documentation for finalizers * error msg with lower case and cover sync case * try to avoid adding json-patch dependency * use Update to remove finalizer * changing status and finalizer during create * do not call Delete() twice
This commit is contained in:
@@ -66,6 +66,17 @@ var substractTest = []struct {
|
||||
{[]string{"a"}, []string{""}, []string{"a"}, false},
|
||||
}
|
||||
|
||||
var removeStringTest = []struct {
|
||||
slice []string
|
||||
item string
|
||||
result []string
|
||||
}{
|
||||
{[]string{"a", "b", "c"}, "b", []string{"a", "c"}},
|
||||
{[]string{"a"}, "b", []string{"a"}},
|
||||
{[]string{"a"}, "a", []string{}},
|
||||
{[]string{}, "a", []string{}},
|
||||
}
|
||||
|
||||
var sliceContaintsTest = []struct {
|
||||
slice []string
|
||||
item string
|
||||
@@ -200,6 +211,15 @@ func TestFindNamedStringSubmatch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveString(t *testing.T) {
|
||||
for _, tt := range removeStringTest {
|
||||
res := RemoveString(tt.slice, tt.item)
|
||||
if !IsEqualIgnoreOrder(res, tt.result) {
|
||||
t.Errorf("RemoveString expected: %#v, got: %#v", tt.result, res)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSliceContains(t *testing.T) {
|
||||
for _, tt := range sliceContaintsTest {
|
||||
res := SliceContains(tt.slice, tt.item)
|
||||
|
||||
Reference in New Issue
Block a user