Skip to content

Commit

Permalink
Updating unit-tests for drpolicy changes
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet Shakya <[email protected]>
  • Loading branch information
abhijeet219 committed Feb 3, 2025
1 parent 546267d commit deb874c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/controller/controllers_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func drclusterConditionExpect(
}

func validateClusterManifest(apiReader client.Reader, drcluster *ramen.DRCluster, disabled bool) {
expectedCount := 8
expectedCount := 3
if disabled {
expectedCount = 0
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/drplacementcontrol_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ func verifyVRGManifestWorkCreatedAsPrimary(namespace, managedCluster string) {
return err == nil
}, timeout, interval).Should(BeTrue())

Expect(len(createdVRGRolesManifest.Spec.Workload.Manifests)).To(Equal(8))
Expect(len(createdVRGRolesManifest.Spec.Workload.Manifests)).To(Equal(3))

vrgClusterRoleManifest := createdVRGRolesManifest.Spec.Workload.Manifests[0]
Expect(vrgClusterRoleManifest).ToNot(BeNil())
Expand Down
16 changes: 16 additions & 0 deletions internal/controller/util/secrets_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
cpcv1 "open-cluster-management.io/config-policy-controller/api/v1"
gppv1 "open-cluster-management.io/governance-policy-propagator/api/v1"
)

Expand All @@ -35,6 +36,7 @@ var _ = Describe("Secrets_Util", func() {
secrets [secretsCount]*corev1.Secret
tstNamespace = "default" // 7 chars
veleroNS = "default" // 7 chars
objects []*cpcv1.ObjectTemplate
)

BeforeEach(func() {
Expand Down Expand Up @@ -194,6 +196,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace, // "default" 7 chars
tstNamespace,
objects,
util.SecretFormatRamen, "")).Should(HaveOccurred())
})
It("Does not create an associated secret policy", func() {
Expand All @@ -207,6 +210,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace, // "default" 7 chars
tstNamespace,
objects,
util.SecretFormatRamen, "")).Should(HaveOccurred())
})
It("Does not create an associated secret policy", func() {
Expand All @@ -223,6 +227,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand All @@ -240,6 +245,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).Should(HaveOccurred())
})
It("Does not create an associated secret policy", func() {
Expand All @@ -256,6 +262,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand All @@ -276,6 +283,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).Should(HaveOccurred())
})
It("No longer protects the secret with a finalizer", func() {
Expand All @@ -296,6 +304,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand All @@ -316,6 +325,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand All @@ -333,6 +343,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[1],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand All @@ -354,6 +365,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen, "")).To(Succeed())
})
It("Protects the secret with a finalizer", func() {
Expand Down Expand Up @@ -506,6 +518,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen,
"")).To(Succeed())
})
Expand All @@ -524,6 +537,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatVelero,
veleroNS)).To(Succeed())
})
Expand All @@ -545,6 +559,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatVelero,
veleroNS)).Should(HaveOccurred())
})
Expand All @@ -561,6 +576,7 @@ var _ = Describe("Secrets_Util", func() {
clusterNames[0],
tstNamespace,
tstNamespace,
objects,
util.SecretFormatRamen,
veleroNS)).Should(HaveOccurred())
})
Expand Down

0 comments on commit deb874c

Please sign in to comment.