Merge pull request #7046 from kaovilai/backup-patch-status-unittest

Update Backup.Status.CSIVolumeSnapshotsCompleted during finalize
This commit is contained in:
Wenkai Yin(尹文开)
2023-11-15 15:32:51 +08:00
committed by GitHub
12 changed files with 261 additions and 70 deletions
+20
View File
@@ -0,0 +1,20 @@
package test
import (
snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
snapshotv1listers "github.com/kubernetes-csi/external-snapshotter/client/v4/listers/volumesnapshot/v1"
"k8s.io/apimachinery/pkg/labels"
)
// VolumeSnapshotLister helps list VolumeSnapshots.
// All objects returned here must be treated as read-only.
//
//go:generate mockery --name VolumeSnapshotLister
type VolumeSnapshotLister interface {
// List lists all VolumeSnapshots in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*snapshotv1.VolumeSnapshot, err error)
// VolumeSnapshots returns an object that can list and get VolumeSnapshots.
VolumeSnapshots(namespace string) snapshotv1listers.VolumeSnapshotNamespaceLister
snapshotv1listers.VolumeSnapshotListerExpansion
}
+73
View File
@@ -0,0 +1,73 @@
// Code generated by mockery v2.35.4. DO NOT EDIT.
package mocks
import (
mock "github.com/stretchr/testify/mock"
labels "k8s.io/apimachinery/pkg/labels"
v1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/listers/volumesnapshot/v1"
)
// VolumeSnapshotLister is an autogenerated mock type for the VolumeSnapshotLister type
type VolumeSnapshotLister struct {
mock.Mock
}
// List provides a mock function with given fields: selector
func (_m *VolumeSnapshotLister) List(selector labels.Selector) ([]*v1.VolumeSnapshot, error) {
ret := _m.Called(selector)
var r0 []*v1.VolumeSnapshot
var r1 error
if rf, ok := ret.Get(0).(func(labels.Selector) ([]*v1.VolumeSnapshot, error)); ok {
return rf(selector)
}
if rf, ok := ret.Get(0).(func(labels.Selector) []*v1.VolumeSnapshot); ok {
r0 = rf(selector)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*v1.VolumeSnapshot)
}
}
if rf, ok := ret.Get(1).(func(labels.Selector) error); ok {
r1 = rf(selector)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// VolumeSnapshots provides a mock function with given fields: namespace
func (_m *VolumeSnapshotLister) VolumeSnapshots(namespace string) volumesnapshotv1.VolumeSnapshotNamespaceLister {
ret := _m.Called(namespace)
var r0 volumesnapshotv1.VolumeSnapshotNamespaceLister
if rf, ok := ret.Get(0).(func(string) volumesnapshotv1.VolumeSnapshotNamespaceLister); ok {
r0 = rf(namespace)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(volumesnapshotv1.VolumeSnapshotNamespaceLister)
}
}
return r0
}
// NewVolumeSnapshotLister creates a new instance of VolumeSnapshotLister. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewVolumeSnapshotLister(t interface {
mock.TestingT
Cleanup(func())
}) *VolumeSnapshotLister {
mock := &VolumeSnapshotLister{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}