@@ -144,6 +144,43 @@ func TestReceiverReconciler_Reconcile(t *testing.T) {
144
144
g .Expect (resultR .Spec .Interval .Duration ).To (BeIdenticalTo (10 * time .Minute ))
145
145
})
146
146
147
+ t .Run ("fails with invalid CEL resource filter" , func (t * testing.T ) {
148
+ g := NewWithT (t )
149
+ g .Expect (k8sClient .Get (context .Background (), client .ObjectKeyFromObject (receiver ), resultR )).To (Succeed ())
150
+
151
+ // Incomplete CEL expression
152
+ patch := []byte (`{"spec":{"resourceFilter":"has(resource.metadata.annotations"}}` )
153
+ g .Expect (k8sClient .Patch (context .Background (), resultR , client .RawPatch (types .MergePatchType , patch ))).To (Succeed ())
154
+
155
+ g .Eventually (func () bool {
156
+ _ = k8sClient .Get (context .Background (), client .ObjectKeyFromObject (receiver ), resultR )
157
+ return ! conditions .IsReady (resultR )
158
+ }, timeout , time .Second ).Should (BeTrue ())
159
+
160
+ g .Expect (conditions .GetReason (resultR , meta .ReadyCondition )).To (BeIdenticalTo (apiv1 .InvalidCELExpressionReason ))
161
+ g .Expect (conditions .GetMessage (resultR , meta .ReadyCondition )).To (ContainSubstring ("annotations" ))
162
+
163
+ g .Expect (conditions .Has (resultR , meta .ReconcilingCondition )).To (BeTrue ())
164
+ g .Expect (conditions .GetReason (resultR , meta .ReconcilingCondition )).To (BeIdenticalTo (meta .ProgressingWithRetryReason ))
165
+ g .Expect (conditions .GetObservedGeneration (resultR , meta .ReconcilingCondition )).To (BeIdenticalTo (resultR .Generation ))
166
+ })
167
+
168
+ t .Run ("recovers when the CEL expression is valid" , func (t * testing.T ) {
169
+ g := NewWithT (t )
170
+ // Incomplete CEL expression
171
+ patch := []byte (`{"spec":{"resourceFilter":"has(resource.metadata.annotations)"}}` )
172
+ g .Expect (k8sClient .Patch (context .Background (), resultR , client .RawPatch (types .MergePatchType , patch ))).To (Succeed ())
173
+
174
+ g .Eventually (func () bool {
175
+ _ = k8sClient .Get (context .Background (), client .ObjectKeyFromObject (receiver ), resultR )
176
+ return conditions .IsReady (resultR )
177
+ }, timeout , time .Second ).Should (BeTrue ())
178
+
179
+ g .Expect (conditions .GetObservedGeneration (resultR , meta .ReadyCondition )).To (BeIdenticalTo (resultR .Generation ))
180
+ g .Expect (resultR .Status .ObservedGeneration ).To (BeIdenticalTo (resultR .Generation ))
181
+ g .Expect (conditions .Has (resultR , meta .ReconcilingCondition )).To (BeFalse ())
182
+ })
183
+
147
184
t .Run ("fails with secret not found error" , func (t * testing.T ) {
148
185
g := NewWithT (t )
149
186
0 commit comments