Skip to content

Complete unit tests for cleanup helpers in kubevirt.go #4633

@coderabbitai

Description

@coderabbitai

Context

As part of PR #4618 (MTV-3353), new cleanup helpers were added to pkg/controller/plan/kubevirt.go to handle plan archival and populator finalizer removal. While some basic tests were added, several cleanup helpers still lack unit test coverage.

Missing Test Coverage

The following helpers need unit tests following the pattern established in pkg/controller/plan/kubevirt_test.go:

  • DeleteAllPlanConfigMaps
  • DeleteAllPlanJobs
  • DeleteAllPlanPopulatorCRs
  • RemoveAllPlanPVCFinalizers
  • removePopulatorFinalizerFromPVC
  • DeleteMigrationPods
  • DeleteMigrationVMs
  • DeleteMigrationDataVolumes

Testing Approach

Tests should follow the existing pattern:

  1. Use createKubeVirtWithPlanUIDAndObjects to set up test fixtures
  2. Create resources with matching and non-matching labels
  3. Call the cleanup method
  4. Assert that only the correct resources are deleted/modified
  5. For finalizer tests, verify finalizers are removed from the correct PVCs

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions