@@ -1515,6 +1515,7 @@ var _ = Describe("Reconciler", func() {
15151515 ctx context.Context
15161516 cancel context.CancelFunc
15171517 reconciledCRs []string
1518+ matchingLabels map [string ]string
15181519 reconciledCRsMutex sync.Mutex
15191520 labeledObj * unstructured.Unstructured
15201521 unlabeledObj * unstructured.Unstructured
@@ -1525,7 +1526,7 @@ var _ = Describe("Reconciler", func() {
15251526 BeforeEach (func () {
15261527 reconciledCRs = []string {}
15271528 mgr = getManagerOrFail ()
1528- matchingLabels : = map [string ]string {"app" : "foo" }
1529+ matchingLabels = map [string ]string {"app" : "foo" }
15291530
15301531 r , err := New (
15311532 WithGroupVersionKind (gvk ),
@@ -1571,22 +1572,24 @@ var _ = Describe("Reconciler", func() {
15711572 AfterEach (func () {
15721573 By ("ensuring the labeled CR is deleted" , func () {
15731574 err := mgr .GetAPIReader ().Get (ctx , labeledObjKey , labeledObj )
1574- if ! apierrors .IsNotFound (err ) {
1575- Expect (err ).ToNot (HaveOccurred ())
1576- labeledObj .SetFinalizers ([]string {})
1577- Expect (mgr .GetClient ().Update (ctx , labeledObj )).To (Succeed ())
1578- Expect (mgr .GetClient ().Delete (ctx , labeledObj )).To (Succeed ())
1575+ if apierrors .IsNotFound (err ) {
1576+ return
15791577 }
1578+ Expect (err ).ToNot (HaveOccurred ())
1579+ labeledObj .SetFinalizers ([]string {})
1580+ Expect (mgr .GetClient ().Update (ctx , labeledObj )).To (Succeed ())
1581+ Expect (mgr .GetClient ().Delete (ctx , labeledObj )).To (Succeed ())
15801582 })
15811583
15821584 By ("ensuring the unlabeled CR is deleted" , func () {
15831585 err := mgr .GetAPIReader ().Get (ctx , unlabeledObjKey , unlabeledObj )
1584- if ! apierrors .IsNotFound (err ) {
1585- Expect (err ).ToNot (HaveOccurred ())
1586- unlabeledObj .SetFinalizers ([]string {})
1587- Expect (mgr .GetClient ().Update (ctx , unlabeledObj )).To (Succeed ())
1588- Expect (mgr .GetClient ().Delete (ctx , unlabeledObj )).To (Succeed ())
1586+ if apierrors .IsNotFound (err ) {
1587+ return
15891588 }
1589+ Expect (err ).ToNot (HaveOccurred ())
1590+ unlabeledObj .SetFinalizers ([]string {})
1591+ Expect (mgr .GetClient ().Update (ctx , unlabeledObj )).To (Succeed ())
1592+ Expect (mgr .GetClient ().Delete (ctx , unlabeledObj )).To (Succeed ())
15901593 })
15911594
15921595 cancel ()
@@ -1618,7 +1621,7 @@ var _ = Describe("Reconciler", func() {
16181621
16191622 By ("updating the unlabeled CR to have matching labels" , func () {
16201623 Expect (mgr .GetClient ().Get (ctx , unlabeledObjKey , unlabeledObj )).To (Succeed ())
1621- unlabeledObj .SetLabels (map [ string ] string { "app" : "foo" } )
1624+ unlabeledObj .SetLabels (matchingLabels )
16221625 Expect (mgr .GetClient ().Update (ctx , unlabeledObj )).To (Succeed ())
16231626 })
16241627
0 commit comments