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
Summary
Follow-up to PR #2 - add comprehensive unit tests for the BackupPlugin functions that require kubernetes client mocking.
Functions needing test coverage
checkVolumePolicies()getFirstKubevirtPVC()Execute()success pathProgress()Cancel()createDataUpload()getDataUploadByOperationID()updateDataUpload()Approach
k8s.io/client-go/kubernetes/fakefor CoreClientsigs.k8s.io/controller-runtime/pkg/client/fakefor CRClientvolumehelper.ShouldPerformSnapshotWithBackupor test with fake configmapsSetDynamicClientFunchook for dynamic client mockingRelated