Skip to content

Commit eeb187c

Browse files
committed
Add test case
1 parent c2981ab commit eeb187c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/cache/cache_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,19 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
261261
err := informerCache.Get(context.Background(), svcKey, svc)
262262
Expect(err).To(HaveOccurred())
263263
})
264+
265+
It("should return an error when context is cancelled", func() {
266+
By("creating a context and cancelling it")
267+
ctx, cancel := context.WithCancel(context.Background())
268+
cancel()
269+
270+
By("listing pods in test-namespace-1 with a cancelled context")
271+
listObj := &kcorev1.PodList{}
272+
err := informerCache.List(ctx, listObj, client.InNamespace(testNamespaceOne))
273+
274+
By("verifying that an error is returned")
275+
Expect(err).To(HaveOccurred())
276+
})
264277
})
265278
Context("with unstructured objects", func() {
266279
It("should be able to list objects that haven't been watched previously", func() {

0 commit comments

Comments
 (0)