@@ -47,6 +47,11 @@ func TestCreateVolumeReplication(t *testing.T) {
4747 },
4848 }
4949
50+ // Add namespace to informer
51+ _ = NamespaceInformer .Informer ().GetIndexer ().Add (& corev1.Namespace {
52+ ObjectMeta : metav1.ObjectMeta {Name : nsName },
53+ })
54+
5055 t .Run ("Successful creation" , func (t * testing.T ) {
5156 err := createVolumeReplication (pvc )
5257 require .NoError (t , err )
@@ -492,6 +497,11 @@ func TestIsVolumeReplicationCorrect(t *testing.T) {
492497 },
493498 }
494499
500+ // Add namespace to informer
501+ _ = NamespaceInformer .Informer ().GetIndexer ().Add (& corev1.Namespace {
502+ ObjectMeta : metav1.ObjectMeta {Name : nsName },
503+ })
504+
495505 tests := []struct {
496506 name string
497507 vr * unstructured.Unstructured
@@ -507,6 +517,7 @@ func TestIsVolumeReplicationCorrect(t *testing.T) {
507517 },
508518 "spec" : map [string ]any {
509519 "volumeReplicationClass" : vrcName ,
520+ "replicationState" : "primary" ,
510521 "dataSource" : map [string ]any {
511522 "apiGroup" : "v1" ,
512523 "kind" : "PersistentVolumeClaim" ,
@@ -517,6 +528,27 @@ func TestIsVolumeReplicationCorrect(t *testing.T) {
517528 },
518529 expected : true ,
519530 },
531+ {
532+ name : "replicationState mismatch" ,
533+ vr : & unstructured.Unstructured {
534+ Object : map [string ]any {
535+ "metadata" : map [string ]any {
536+ "name" : pvcName ,
537+ "namespace" : nsName ,
538+ },
539+ "spec" : map [string ]any {
540+ "volumeReplicationClass" : vrcName ,
541+ "replicationState" : "secondary" ,
542+ "dataSource" : map [string ]any {
543+ "apiGroup" : "v1" ,
544+ "kind" : "PersistentVolumeClaim" ,
545+ "name" : pvcName ,
546+ },
547+ },
548+ },
549+ },
550+ expected : false ,
551+ },
520552 {
521553 name : "volumeReplicationClass mismatch" ,
522554 vr : & unstructured.Unstructured {
@@ -833,6 +865,17 @@ func TestIsPvcPaused(t *testing.T) {
833865 namespace : pausedNs ,
834866 expected : false , // PVC takes precedence, and invalid is not true
835867 },
868+ {
869+ name : "PVC empty pause value, NS paused" ,
870+ pvc : & corev1.PersistentVolumeClaim {
871+ ObjectMeta : metav1.ObjectMeta {
872+ Namespace : nsName ,
873+ Annotations : map [string ]string {constants .PauseAnnotation : "" },
874+ },
875+ },
876+ namespace : pausedNs ,
877+ expected : true , // It falls back to NS now
878+ },
836879 }
837880
838881 for _ , tt := range tests {
0 commit comments