@@ -172,6 +172,50 @@ func TestClusterReconciler(t *testing.T) {
172
172
}, timeout ).Should (BeTrue ())
173
173
})
174
174
175
+ t .Run ("Should successfully patch a cluster object if the spec diff is empty but the status conditions diff is not" , func (t * testing.T ) {
176
+ g := NewWithT (t )
177
+
178
+ // Setup
179
+ cluster := & clusterv1.Cluster {
180
+ ObjectMeta : metav1.ObjectMeta {
181
+ GenerateName : "test3-" ,
182
+ Namespace : ns .Name ,
183
+ },
184
+ }
185
+ g .Expect (env .Create (ctx , cluster )).To (Succeed ())
186
+ key := client.ObjectKey {Name : cluster .Name , Namespace : cluster .Namespace }
187
+ defer func () {
188
+ err := env .Delete (ctx , cluster )
189
+ g .Expect (err ).ToNot (HaveOccurred ())
190
+ }()
191
+
192
+ // Wait for reconciliation to happen.
193
+ g .Eventually (func () bool {
194
+ if err := env .Get (ctx , key , cluster ); err != nil {
195
+ return false
196
+ }
197
+ return len (cluster .Finalizers ) > 0
198
+ }, timeout ).Should (BeTrue ())
199
+
200
+ // Patch
201
+ g .Eventually (func () bool {
202
+ ph , err := patch .NewHelper (cluster , env )
203
+ g .Expect (err ).ToNot (HaveOccurred ())
204
+ conditions .MarkTrue (cluster , clusterv1 .InfrastructureReadyCondition )
205
+ g .Expect (ph .Patch (ctx , cluster , patch.WithStatusObservedGeneration {})).To (Succeed ())
206
+ return true
207
+ }, timeout ).Should (BeTrue ())
208
+
209
+ // Assertions
210
+ g .Eventually (func () bool {
211
+ instance := & clusterv1.Cluster {}
212
+ if err := env .Get (ctx , key , instance ); err != nil {
213
+ return false
214
+ }
215
+ return conditions .IsTrue (cluster , clusterv1 .InfrastructureReadyCondition )
216
+ }, timeout ).Should (BeTrue ())
217
+ })
218
+
175
219
t .Run ("Should successfully patch a cluster object if both the spec diff and status diff are non empty" , func (t * testing.T ) {
176
220
g := NewWithT (t )
177
221
0 commit comments