From f894f8196d9266915424e2cefc9e4eb480ae6f5e Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Mon, 9 May 2022 07:59:38 -0700 Subject: [PATCH] etcd3/store: update creation test to use storage client There is no functional difference between checking for an empty key using the database client and doing so with the storage interface. Using the latter allows this test to be more portable. Signed-off-by: Steve Kuznetsov --- .../k8s.io/apiserver/pkg/storage/etcd3/store_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/store_test.go b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/store_test.go index 205dfce65c8..4013a9a3237 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/store_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/store_test.go @@ -115,16 +115,11 @@ func TestCreate(t *testing.T) { obj := &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", SelfLink: "testlink"}} // verify that kv pair is empty before set - getResp, err := etcdClient.KV.Get(ctx, key) - if err != nil { - t.Fatalf("etcdClient.KV.Get failed: %v", err) - } - if len(getResp.Kvs) != 0 { - t.Fatalf("expecting empty result on key: %s", key) + if err := store.Get(ctx, key, storage.GetOptions{}, out); !storage.IsNotFound(err) { + t.Fatalf("expecting empty result on key %s, got %v", key, err) } - err = store.Create(ctx, key, obj, out, 0) - if err != nil { + if err := store.Create(ctx, key, obj, out, 0); err != nil { t.Fatalf("Set failed: %v", err) } // basic tests of the output