@@ -1975,10 +1975,10 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
19751975 Expect (err ).NotTo (HaveOccurred ())
19761976
19771977 pod := & corev1.Pod {}
1978- By ("indexing pods with namespace before starting" )
1979- fieldName1 := "indexByNamespace "
1978+ By ("indexing pods with label before starting" )
1979+ fieldName1 := "indexByLabel "
19801980 indexFunc1 := func (obj client.Object ) []string {
1981- return []string {obj .(* corev1.Pod ).Namespace }
1981+ return []string {obj .(* corev1.Pod ).Labels [ "common-label" ] }
19821982 }
19831983 Expect (informer .IndexField (context .TODO (), pod , fieldName1 , indexFunc1 )).To (Succeed ())
19841984 By ("indexing pods with restart policy before starting" )
@@ -1995,23 +1995,23 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
19951995 }()
19961996 Expect (informer .WaitForCacheSync (informerCacheCtx )).To (BeTrue ())
19971997
1998- By ("listing pods with namespace index" )
1998+ By ("listing pods with label index" )
19991999 listObj := & corev1.PodList {}
20002000 Expect (informer .List (context .Background (), listObj ,
2001- client.MatchingFields {fieldName1 : testNamespaceTwo })).To (Succeed ())
2002- Expect (listObj .Items ).To (HaveLen (3 ))
2001+ client.MatchingFields {fieldName1 : "common" })).To (Succeed ())
2002+ Expect (listObj .Items ).To (HaveLen (2 ))
20032003
20042004 By ("listing pods with restart policy index" )
20052005 listObj = & corev1.PodList {}
20062006 Expect (informer .List (context .Background (), listObj ,
2007- client.MatchingFields {fieldName2 : string (corev1 .RestartPolicyAlways )})).To (Succeed ())
2008- Expect (listObj .Items ).To (HaveLen (2 ))
2007+ client.MatchingFields {fieldName2 : string (corev1 .RestartPolicyNever )})).To (Succeed ())
2008+ Expect (listObj .Items ).To (HaveLen (3 ))
20092009
2010- By ("listing Namespaces with both fixed indexers 1 and 2" )
2010+ By ("listing pods with both fixed indexers 1 and 2" )
20112011 listObj = & corev1.PodList {}
20122012 Expect (informer .List (context .Background (), listObj ,
2013- client.MatchingFields {fieldName1 : testNamespaceTwo , fieldName2 : string (corev1 .RestartPolicyAlways )})).To (Succeed ())
2014- Expect (listObj .Items ).To (HaveLen (2 ))
2013+ client.MatchingFields {fieldName1 : "common" , fieldName2 : string (corev1 .RestartPolicyNever )})).To (Succeed ())
2014+ Expect (listObj .Items ).To (HaveLen (1 ))
20152015 })
20162016 })
20172017 Context ("with unstructured objects" , func () {
0 commit comments