@@ -122,8 +122,8 @@ var _ = Describe("Fake client", func() {
122
122
Expect (list .Items ).To (HaveLen (2 ))
123
123
})
124
124
125
- It ("should support filtering by labels" , func () {
126
- By ("Listing deployments with a particular label" )
125
+ It ("should support filtering by labels and their values " , func () {
126
+ By ("Listing deployments with a particular label and value " )
127
127
list := & appsv1.DeploymentList {}
128
128
err := cl .List (nil , list , client .InNamespace ("ns1" ),
129
129
client .MatchingLabels (map [string ]string {
@@ -134,6 +134,16 @@ var _ = Describe("Fake client", func() {
134
134
Expect (list .Items ).To (ConsistOf (* dep2 ))
135
135
})
136
136
137
+ It ("should support filtering by label existence" , func () {
138
+ By ("Listing deployments with a particular label" )
139
+ list := & appsv1.DeploymentList {}
140
+ err := cl .List (nil , list , client .InNamespace ("ns1" ),
141
+ client.HasLabels {"test-label" })
142
+ Expect (err ).To (BeNil ())
143
+ Expect (list .Items ).To (HaveLen (1 ))
144
+ Expect (list .Items ).To (ConsistOf (* dep2 ))
145
+ })
146
+
137
147
It ("should be able to Create" , func () {
138
148
By ("Creating a new configmap" )
139
149
newcm := & corev1.ConfigMap {
0 commit comments