@@ -21,6 +21,7 @@ import (
21
21
"context"
22
22
"errors"
23
23
"strconv"
24
+ "strings"
24
25
25
26
. "github.com/onsi/ginkgo"
26
27
. "github.com/onsi/gomega"
@@ -543,6 +544,33 @@ var _ = Describe("ActionClient", func() {
543
544
Expect (err ).NotTo (BeNil ())
544
545
})
545
546
})
547
+
548
+ var _ = Describe ("containsResourcePolicyKeep" , func () {
549
+ It ("returns true on base case" , func () {
550
+ annotations := map [string ]string {kube .ResourcePolicyAnno : kube .KeepPolicy }
551
+ Expect (containsResourcePolicyKeep (annotations )).To (BeTrue ())
552
+ })
553
+ It ("returns false when annotation key is not found" , func () {
554
+ annotations := map [string ]string {"not-" + kube .ResourcePolicyAnno : kube .KeepPolicy }
555
+ Expect (containsResourcePolicyKeep (annotations )).To (BeFalse ())
556
+ })
557
+ It ("returns false when annotation value is not 'keep'" , func () {
558
+ annotations := map [string ]string {"not-" + kube .ResourcePolicyAnno : "not-" + kube .KeepPolicy }
559
+ Expect (containsResourcePolicyKeep (annotations )).To (BeFalse ())
560
+ })
561
+ It ("returns true when annotation is uppercase" , func () {
562
+ annotations := map [string ]string {kube .ResourcePolicyAnno : strings .ToUpper (kube .KeepPolicy )}
563
+ Expect (containsResourcePolicyKeep (annotations )).To (BeTrue ())
564
+ })
565
+ It ("returns true when annotation is has whitespace prefix and/or suffix" , func () {
566
+ annotations := map [string ]string {kube .ResourcePolicyAnno : " " + kube .KeepPolicy + " " }
567
+ Expect (containsResourcePolicyKeep (annotations )).To (BeTrue ())
568
+ })
569
+ It ("returns true when annotation is uppercase and has whitespace prefix and/or suffix" , func () {
570
+ annotations := map [string ]string {kube .ResourcePolicyAnno : " " + strings .ToUpper (kube .KeepPolicy ) + " " }
571
+ Expect (containsResourcePolicyKeep (annotations )).To (BeTrue ())
572
+ })
573
+ })
546
574
})
547
575
548
576
func manifestToObjects (manifest string ) []client.Object {
0 commit comments