66 "testing"
77
88 corev1 "k8s.io/api/core/v1"
9+ v1 "k8s.io/api/core/v1"
910
1011 "github.com/go-logr/logr"
1112 oadpv1alpha1 "github.com/openshift/oadp-operator/api/v1alpha1"
@@ -1305,7 +1306,7 @@ func TestDPAReconciler_updateBSLFromSpec(t *testing.T) {
13051306 }
13061307}
13071308
1308- func TestDPAReconciler_ensureBSLProviderMapping (t * testing.T ) {
1309+ func TestDPAReconciler_ensureBackupLocationHasVeleroOrCloudStorage (t * testing.T ) {
13091310 tests := []struct {
13101311 name string
13111312 dpa * oadpv1alpha1.DataProtectionApplication
@@ -1341,7 +1342,7 @@ func TestDPAReconciler_ensureBSLProviderMapping(t *testing.T) {
13411342 wantErr : false ,
13421343 },
13431344 {
1344- name : "two bsl configured for aws provider " ,
1345+ name : "wantErr: a bsl has both velero and cloudstorage configured " ,
13451346 dpa : & oadpv1alpha1.DataProtectionApplication {
13461347 ObjectMeta : metav1.ObjectMeta {
13471348 Name : "foo" ,
@@ -1353,12 +1354,41 @@ func TestDPAReconciler_ensureBSLProviderMapping(t *testing.T) {
13531354 Velero : & velerov1.BackupStorageLocationSpec {
13541355 Provider : "aws" ,
13551356 },
1357+ CloudStorage : & oadpv1alpha1.CloudStorageLocation {
1358+ CloudStorageRef : v1.LocalObjectReference {
1359+ Name : "foo" ,
1360+ },
1361+ },
13561362 },
1363+ },
1364+ },
1365+ },
1366+ wantErr : true ,
1367+ },
1368+ {
1369+ name : "two bsl configured per provider" ,
1370+ dpa : & oadpv1alpha1.DataProtectionApplication {
1371+ ObjectMeta : metav1.ObjectMeta {
1372+ Name : "foo" ,
1373+ Namespace : "test-ns" ,
1374+ },
1375+ Spec : oadpv1alpha1.DataProtectionApplicationSpec {
1376+ BackupLocations : []oadpv1alpha1.BackupLocation {
13571377 {
13581378 Velero : & velerov1.BackupStorageLocationSpec {
13591379 Provider : "aws" ,
13601380 },
13611381 },
1382+ {
1383+ Velero : & velerov1.BackupStorageLocationSpec {
1384+ Provider : "aws" ,
1385+ },
1386+ },
1387+ {
1388+ Velero : & velerov1.BackupStorageLocationSpec {
1389+ Provider : "azure" ,
1390+ },
1391+ },
13621392 {
13631393 Velero : & velerov1.BackupStorageLocationSpec {
13641394 Provider : "azure" ,
@@ -1371,13 +1401,13 @@ func TestDPAReconciler_ensureBSLProviderMapping(t *testing.T) {
13711401 },
13721402 {
13731403 Velero : & velerov1.BackupStorageLocationSpec {
1374- Provider : "thirdpary-objectstorage-provider " ,
1404+ Provider : "gcp " ,
13751405 },
13761406 },
13771407 },
13781408 },
13791409 },
1380- wantErr : true ,
1410+ wantErr : false ,
13811411 },
13821412 }
13831413 for _ , tt := range tests {
@@ -1389,7 +1419,7 @@ func TestDPAReconciler_ensureBSLProviderMapping(t *testing.T) {
13891419 r := & DPAReconciler {
13901420 Scheme : scheme ,
13911421 }
1392- if err := r .ensureBSLProviderMapping (tt .dpa ); (err != nil ) != tt .wantErr {
1422+ if err := r .ensureBackupLocationHasVeleroOrCloudStorage (tt .dpa ); (err != nil ) != tt .wantErr {
13931423 t .Errorf ("ensureBSLProviderMapping() error = %v, wantErr %v" , err , tt .wantErr )
13941424 }
13951425 })
0 commit comments