From 487761f4e2543114db158f0d59e598dedc481882 Mon Sep 17 00:00:00 2001 From: Madhav Jivrajani Date: Fri, 15 Jul 2022 12:22:04 +0530 Subject: [PATCH] cacher: Use PodList type for use in GetList Using a Pod type in a GetList() call in a test can panic at worst and error out at best. Here, neither happened because the error condition being tested for (cacher being stopped or not) gets returned before the list pointer can be enforced. This commit changes the above to use PodList. Signed-off-by: Madhav Jivrajani --- .../apiserver/pkg/storage/cacher/cacher_whitebox_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index 5f0ba257a6b..1616fe6b1f8 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -647,10 +647,11 @@ func TestCacheDontAcceptRequestsStopped(t *testing.T) { t.Fatalf("Success to create Get: %v", err) } + listResult := &example.PodList{} err = cacher.GetList(context.TODO(), "pods/ns", storage.ListOptions{ ResourceVersion: "1", Recursive: true, - }, result) + }, listResult) if err == nil { t.Fatalf("Success to create GetList: %v", err) } @@ -660,7 +661,6 @@ func TestCacheDontAcceptRequestsStopped(t *testing.T) { case <-time.After(wait.ForeverTestTimeout): t.Errorf("timed out waiting for watch to close") } - } func TestTimeBucketWatchersBasic(t *testing.T) {