mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
storage: etcd: TestUnconditionalDelete: use sub-tests
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
parent
b6a6625217
commit
dbb00694f6
@ -300,34 +300,39 @@ func TestUnconditionalDelete(t *testing.T) {
|
|||||||
key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
|
key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
name string
|
||||||
key string
|
key string
|
||||||
expectedObj *example.Pod
|
expectedObj *example.Pod
|
||||||
expectNotFoundErr bool
|
expectNotFoundErr bool
|
||||||
}{{ // test unconditional delete on existing key
|
}{{
|
||||||
|
name: "test unconditional delete on existing key",
|
||||||
key: key,
|
key: key,
|
||||||
expectedObj: storedObj,
|
expectedObj: storedObj,
|
||||||
expectNotFoundErr: false,
|
expectNotFoundErr: false,
|
||||||
}, { // test unconditional delete on non-existing key
|
}, {
|
||||||
|
name: "test unconditional delete on non-existing key",
|
||||||
key: "/non-existing",
|
key: "/non-existing",
|
||||||
expectedObj: nil,
|
expectedObj: nil,
|
||||||
expectNotFoundErr: true,
|
expectNotFoundErr: true,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for i, tt := range tests {
|
for _, tt := range tests {
|
||||||
out := &example.Pod{} // reset
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
err := store.Delete(ctx, tt.key, out, nil, storage.ValidateAllObjectFunc, nil)
|
out := &example.Pod{} // reset
|
||||||
if tt.expectNotFoundErr {
|
err := store.Delete(ctx, tt.key, out, nil, storage.ValidateAllObjectFunc, nil)
|
||||||
if err == nil || !storage.IsNotFound(err) {
|
if tt.expectNotFoundErr {
|
||||||
t.Errorf("#%d: expecting not found error, but get: %s", i, err)
|
if err == nil || !storage.IsNotFound(err) {
|
||||||
|
t.Errorf("%s: expecting not found error, but get: %s", tt.name, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
continue
|
if err != nil {
|
||||||
}
|
t.Fatalf("%s: Delete failed: %v", tt.name, err)
|
||||||
if err != nil {
|
}
|
||||||
t.Fatalf("Delete failed: %v", err)
|
if !reflect.DeepEqual(tt.expectedObj, out) {
|
||||||
}
|
t.Errorf("%s: pod want=%#v, get=%#v", tt.name, tt.expectedObj, out)
|
||||||
if !reflect.DeepEqual(tt.expectedObj, out) {
|
}
|
||||||
t.Errorf("#%d: pod want=%#v, get=%#v", i, tt.expectedObj, out)
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user