@@ -1419,6 +1419,69 @@ var _ = Describe("Reconciler", func() {
14191419 verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
14201420 })
14211421
1422+ By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1423+ err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1424+ Expect (apierrors .IsNotFound (err )).To (BeTrue ())
1425+ })
1426+ })
1427+ })
1428+ When ("pause-reconcile annotation is present" , func () {
1429+ It ("pauses reconciliation" , func () {
1430+ By ("adding a pause-reconcile handler to the Reconciler" , func () {
1431+ pauseHandler := WithPauseReconcileHandler (PauseReconcileIfAnnotationTrue ("my.domain/pause-reconcile" ))
1432+ Expect (pauseHandler (r )).To (Succeed ())
1433+ })
1434+
1435+ By ("adding the pause-reconcile annotation to the CR" , func () {
1436+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1437+ obj .SetAnnotations (map [string ]string {"my.domain/pause-reconcile" : "true" })
1438+ obj .Object ["spec" ] = map [string ]interface {}{"replicaCount" : "666" }
1439+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1440+ })
1441+
1442+ By ("deleting the CR" , func () {
1443+ Expect (mgr .GetClient ().Delete (ctx , obj )).To (Succeed ())
1444+ })
1445+
1446+ By ("successfully reconciling a request when paused" , func () {
1447+ res , err := r .Reconcile (ctx , req )
1448+ Expect (res ).To (Equal (reconcile.Result {}))
1449+ Expect (err ).ToNot (HaveOccurred ())
1450+ })
1451+
1452+ By ("getting the CR" , func () {
1453+ Expect (mgr .GetAPIReader ().Get (ctx , objKey , obj )).To (Succeed ())
1454+ })
1455+
1456+ By ("verifying the CR status is Paused" , func () {
1457+ objStat := & objStatus {}
1458+ Expect (runtime .DefaultUnstructuredConverter .FromUnstructured (obj .Object , objStat )).To (Succeed ())
1459+ Expect (objStat .Status .Conditions .IsTrueFor (conditions .TypePaused )).To (BeTrue ())
1460+ })
1461+
1462+ By ("verifying the release has not changed" , func () {
1463+ rel , err := ac .Get (obj .GetName ())
1464+ Expect (err ).ToNot (HaveOccurred ())
1465+ Expect (rel ).NotTo (BeNil ())
1466+ Expect (* rel ).To (Equal (* currentRelease ))
1467+ })
1468+
1469+ By ("removing the pause-reconcile annotation from the CR" , func () {
1470+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1471+ obj .SetAnnotations (nil )
1472+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1473+ })
1474+
1475+ By ("successfully reconciling a request" , func () {
1476+ res , err := r .Reconcile (ctx , req )
1477+ Expect (res ).To (Equal (reconcile.Result {}))
1478+ Expect (err ).ToNot (HaveOccurred ())
1479+ })
1480+
1481+ By ("verifying the release is uninstalled" , func () {
1482+ verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1483+ })
1484+
14221485 By ("ensuring the finalizer is removed and the CR is deleted" , func () {
14231486 err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
14241487 Expect (apierrors .IsNotFound (err )).To (BeTrue ())
0 commit comments