diff --git a/pkg/controller/velerobackup/velerobackup_controller_test.go b/pkg/controller/velerobackup/velerobackup_controller_test.go index 3ca2ff34874..a4755a75e81 100644 --- a/pkg/controller/velerobackup/velerobackup_controller_test.go +++ b/pkg/controller/velerobackup/velerobackup_controller_test.go @@ -116,9 +116,9 @@ func TestReconcile(t *testing.T) { }, expectedResult: reconcile.Result{}, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), - testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")), - testdnszone.Build(dnsZoneBase(), testdnszone.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), + testsyncset.Build(syncSetBase()), + testdnszone.Build(dnsZoneBase()), testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum( []runtime.Object{ testclusterdeployment.Build(clusterDeploymentBase()), @@ -150,7 +150,7 @@ func TestReconcile(t *testing.T) { }, expectedResult: reconcile.Result{}, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupRef(hivev1.BackupReference{Name: "notarealbackup", Namespace: namespace}), testcheckpoint.WithLastBackupTime(fiveHoursAgo), @@ -186,8 +186,8 @@ func TestReconcile(t *testing.T) { RequeueAfter: ((3 * time.Minute) - twoMinuteDuration), }, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), - testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), + testsyncset.Build(syncSetBase()), testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupRef(hivev1.BackupReference{Name: "notarealbackup", Namespace: namespace}), testcheckpoint.WithLastBackupTime(twoMinutesAgo), @@ -218,8 +218,8 @@ func TestReconcile(t *testing.T) { }, expectedResult: reconcile.Result{}, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), - testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), + testsyncset.Build(syncSetBase()), testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum( []runtime.Object{ testclusterdeployment.Build(clusterDeploymentBase()), @@ -249,8 +249,8 @@ func TestReconcile(t *testing.T) { }, expectedResult: reconcile.Result{}, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), - testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), + testsyncset.Build(syncSetBase()), testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum( []runtime.Object{ testclusterdeployment.Build(clusterDeploymentBase()), @@ -331,17 +331,17 @@ func TestGetRuntimeObjects(t *testing.T) { testclusterdeployment.Build(clusterDeploymentBase()), }, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), }, }, { name: "2 ClusterDeployments in different namespaces", existingObjects: []runtime.Object{ testclusterdeployment.Build(clusterDeploymentBase()), - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.Generic(generic.WithNamespace("not the correct namespace")), testclusterdeployment.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.Generic(generic.WithNamespace("not the correct namespace"))), }, expectedObjects: []runtime.Object{ - testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), + testclusterdeployment.Build(clusterDeploymentBase()), }, }, } @@ -383,7 +383,7 @@ func TestGetNamespaceCheckpoint(t *testing.T) { name: "Existing Checkpoint", expectedFound: true, existingObjects: []runtime.Object{testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"))}, - expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"), testcheckpoint.WithTypeMeta(), testcheckpoint.WithResourceVersion("999")), + expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"), testcheckpoint.WithTypeMeta()), expectedError: nil, }, } @@ -441,7 +441,7 @@ func TestCreateOrUpdateNamespaceCheckpoint(t *testing.T) { existingObjects: []runtime.Object{ testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE")), }, - expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE"), testcheckpoint.WithTypeMeta(), testcheckpoint.WithResourceVersion("999")), + expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE"), testcheckpoint.WithTypeMeta()), expectedError: statusErr, }, { @@ -480,7 +480,7 @@ func TestCalculateObjectsChecksumWithoutStatus(t *testing.T) { }{ { name: "Valid ClusterDeployment Checksum", - object: testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")), + object: testclusterdeployment.Build(clusterDeploymentBase()), expectedChecksum: calculateClusterDeploymentChecksum(testclusterdeployment.Build(clusterDeploymentBase())), }, { diff --git a/pkg/test/clusterdeployment/clusterdeployment.go b/pkg/test/clusterdeployment/clusterdeployment.go index a4eb6eb93c8..1480bff4302 100644 --- a/pkg/test/clusterdeployment/clusterdeployment.go +++ b/pkg/test/clusterdeployment/clusterdeployment.go @@ -81,11 +81,6 @@ func WithName(name string) Option { return Generic(generic.WithName(name)) } -// WithResourceVersion sets the specified resource version on the supplied object. -func WithResourceVersion(resourceVersion string) Option { - return Generic(generic.WithResourceVersion(resourceVersion)) -} - // WithNamespace sets the object.Namespace field when building an object with Build. func WithNamespace(namespace string) Option { return Generic(generic.WithNamespace(namespace)) diff --git a/pkg/test/syncset/syncset.go b/pkg/test/syncset/syncset.go index 30f09251e70..539e15ed574 100644 --- a/pkg/test/syncset/syncset.go +++ b/pkg/test/syncset/syncset.go @@ -127,8 +127,3 @@ func WithPatches(patches ...hivev1.SyncObjectPatch) Option { syncSet.Spec.Patches = patches } } - -// WithResourceVersion sets the specified resource version on the supplied object. -func WithResourceVersion(resourceVersion string) Option { - return Generic(generic.WithResourceVersion(resourceVersion)) -}