@@ -63,7 +63,7 @@ func TestCreateVolumeReplication(t *testing.T) {
6363 require .Equal (t , vrcName , vr .GetAnnotations ()[constants .VrcValueAnnotation ])
6464 require .Equal (t , "value" , vr .GetAnnotations ()["other-annotation" ])
6565 require .Equal (t , "value" , vr .GetLabels ()["other-label" ])
66- require .Equal (t , pvcName , vr .GetLabels ()[constants .VrParentLabel ])
66+ require .Equal (t , pvcName , vr .GetLabels ()[constants .ParentLabel ])
6767
6868 // Check spec
6969 spec , ok := vr .Object ["spec" ].(map [string ]interface {})
@@ -145,9 +145,9 @@ func TestIsParentLabelPresent(t *testing.T) {
145145 {
146146 name : "present" ,
147147 labels : map [string ]string {
148- "a" : "b" ,
149- "c" : "d" ,
150- constants .VrParentLabel : "test" ,
148+ "a" : "b" ,
149+ "c" : "d" ,
150+ constants .ParentLabel : "test" ,
151151 },
152152 result : true ,
153153 },
@@ -159,7 +159,7 @@ func TestIsParentLabelPresent(t *testing.T) {
159159 {
160160 name : "empty value" ,
161161 labels : map [string ]string {
162- constants .VrParentLabel : "" ,
162+ constants .ParentLabel : "" ,
163163 },
164164 result : false ,
165165 },
@@ -288,7 +288,7 @@ func TestGetStorageClassGroup(t *testing.T) {
288288 ObjectMeta : metav1.ObjectMeta {
289289 Name : stcName ,
290290 Labels : map [string ]string {
291- constants .VrStorageClassGroup : groupName ,
291+ constants .StorageClassGroup : groupName ,
292292 },
293293 },
294294 }
@@ -333,7 +333,7 @@ func TestGetLabelsWithParent(t *testing.T) {
333333 parent : "test" ,
334334 labels : map [string ]string {},
335335 result : map [string ]string {
336- constants .VrParentLabel : "test" ,
336+ constants .ParentLabel : "test" ,
337337 },
338338 },
339339 {
@@ -344,29 +344,29 @@ func TestGetLabelsWithParent(t *testing.T) {
344344 "c" : "d" ,
345345 },
346346 result : map [string ]string {
347- constants .VrParentLabel : "test" ,
348- "a" : "b" ,
349- "c" : "d" ,
347+ constants .ParentLabel : "test" ,
348+ "a" : "b" ,
349+ "c" : "d" ,
350350 },
351351 },
352352 {
353353 name : "nil labels" ,
354354 parent : "test" ,
355355 labels : nil ,
356356 result : map [string ]string {
357- constants .VrParentLabel : "test" ,
357+ constants .ParentLabel : "test" ,
358358 },
359359 },
360360 {
361361 name : "label already present" ,
362362 parent : "new-test" ,
363363 labels : map [string ]string {
364- constants .VrParentLabel : "old-test" ,
365- "a" : "b" ,
364+ constants .ParentLabel : "old-test" ,
365+ "a" : "b" ,
366366 },
367367 result : map [string ]string {
368- constants .VrParentLabel : "new-test" ,
369- "a" : "b" ,
368+ constants .ParentLabel : "new-test" ,
369+ "a" : "b" ,
370370 },
371371 },
372372 }
@@ -607,3 +607,58 @@ func TestIsVolumeReplicationCorrect(t *testing.T) {
607607 })
608608 }
609609}
610+
611+ func TestGetPvcProvisioner (t * testing.T ) {
612+ t .Parallel ()
613+
614+ tests := []struct {
615+ name string
616+ annotations map [string ]string
617+ expected string
618+ }{
619+ {
620+ name : "standard annotation" ,
621+ annotations : map [string ]string {
622+ constants .StorageProvisionerAnnotation : "standard-provisioner" ,
623+ },
624+ expected : "standard-provisioner" ,
625+ },
626+ {
627+ name : "deprecated annotation" ,
628+ annotations : map [string ]string {
629+ constants .DeprecatedStorageProvisionerAnnotation : "deprecated-provisioner" ,
630+ },
631+ expected : "deprecated-provisioner" ,
632+ },
633+ {
634+ name : "both annotations - standard takes precedence" ,
635+ annotations : map [string ]string {
636+ constants .StorageProvisionerAnnotation : "standard-provisioner" ,
637+ constants .DeprecatedStorageProvisionerAnnotation : "deprecated-provisioner" ,
638+ },
639+ expected : "standard-provisioner" ,
640+ },
641+ {
642+ name : "no annotations" ,
643+ annotations : map [string ]string {},
644+ expected : "" ,
645+ },
646+ {
647+ name : "nil annotations" ,
648+ annotations : nil ,
649+ expected : "" ,
650+ },
651+ }
652+
653+ for _ , tt := range tests {
654+ t .Run (tt .name , func (t * testing.T ) {
655+ pvc := & corev1.PersistentVolumeClaim {
656+ ObjectMeta : metav1.ObjectMeta {
657+ Annotations : tt .annotations ,
658+ },
659+ }
660+ result := getPvcProvisioner (pvc )
661+ require .Equal (t , tt .expected , result )
662+ })
663+ }
664+ }
0 commit comments