Skip to content

Commit

Permalink
Migration create mutator, tests: Avoid name collisions
Browse files Browse the repository at this point in the history
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] #11561
[2] #11625

Signed-off-by: Orel Misan <omisan@redhat.com>
  • Loading branch information
orelmisan committed Apr 4, 2024
1 parent f4aad6e commit ebe712c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ebe712c

Please sign in to comment.