Skip to content

Add unit tests for volume policy checking and DataUpload operations #5

@shubham-pampattiwar

Description

@shubham-pampattiwar

Summary

Follow-up to PR #2 - add comprehensive unit tests for the BackupPlugin functions that require kubernetes client mocking.

Functions needing test coverage

Function Requires
checkVolumePolicies() Mock CRClient, CoreClient, volumehelper
getFirstKubevirtPVC() Mock CRClient, CoreClient, volumehelper
Execute() success path Mock dynamic client for DataUpload creation
Progress() Mock dynamic client for DataUpload status
Cancel() Mock dynamic client
createDataUpload() Mock dynamic client
getDataUploadByOperationID() Mock dynamic client
updateDataUpload() Mock dynamic client

Approach

  • Use k8s.io/client-go/kubernetes/fake for CoreClient
  • Use sigs.k8s.io/controller-runtime/pkg/client/fake for CRClient
  • Mock volumehelper.ShouldPerformSnapshotWithBackup or test with fake configmaps
  • Use the existing SetDynamicClientFunc hook for dynamic client mocking

Related

Metadata

Metadata

Assignees

No one assigned

    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