From ebe712c5945bd5e22b96ccc905c21cbab5b7880f Mon Sep 17 00:00:00 2001 From: Orel Misan Date: Thu, 4 Apr 2024 13:07:00 +0300 Subject: [PATCH] Migration create mutator, tests: Avoid name collisions PR #11561 introduced two new functions to the unit test file: - newAdmissionReview - expectedJSONPatch Since: 1. Other mutators' tests will have similar functions 2. The tests share the same `mutators_test` package add a suffix to differentiate them and avoid name collisions. [1] https://github.com/kubevirt/kubevirt/pull/11561 [2] https://github.com/kubevirt/kubevirt/pull/11625 Signed-off-by: Orel Misan --- .../mutators/migration-create-mutator_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/virt-api/webhooks/mutating-webhook/mutators/migration-create-mutator_test.go b/pkg/virt-api/webhooks/mutating-webhook/mutators/migration-create-mutator_test.go index 674a731bdced..5b0f4993c857 100644 --- a/pkg/virt-api/webhooks/mutating-webhook/mutators/migration-create-mutator_test.go +++ b/pkg/virt-api/webhooks/mutating-webhook/mutators/migration-create-mutator_test.go @@ -41,12 +41,12 @@ var _ = Describe("VirtualMachineInstanceMigration Mutator", func() { It("Should mutate the VirtualMachineInstanceMigration object", func() { migration := newMigration() - admissionReview, err := newAdmissionReview(migration) + admissionReview, err := newAdmissionReviewForVMIMCreation(migration) Expect(err).ToNot(HaveOccurred()) mutator := &mutators.MigrationCreateMutator{} - expectedJSONPatch, err := expectedJSONPatch( + expectedJSONPatch, err := expectedJSONPatchForVMIMCreation( expectedMigrationObjectMeta(migration.ObjectMeta, migration.Spec.VMIName), ) Expect(err).NotTo(HaveOccurred()) @@ -72,7 +72,7 @@ func newMigration() *v1.VirtualMachineInstanceMigration { } } -func newAdmissionReview(migration *v1.VirtualMachineInstanceMigration) (*admissionv1.AdmissionReview, error) { +func newAdmissionReviewForVMIMCreation(migration *v1.VirtualMachineInstanceMigration) (*admissionv1.AdmissionReview, error) { migrationBytes, err := json.Marshal(migration) if err != nil { return nil, err @@ -101,7 +101,7 @@ func expectedMigrationObjectMeta(currentObjectMeta k8smetav1.ObjectMeta, vmiName return expectedObjectMeta } -func expectedJSONPatch(expectedObjectMeta k8smetav1.ObjectMeta) ([]byte, error) { +func expectedJSONPatchForVMIMCreation(expectedObjectMeta k8smetav1.ObjectMeta) ([]byte, error) { return patch.GeneratePatchPayload( patch.PatchOperation{ Op: patch.PatchReplaceOp,