mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-21 22:56:05 +00:00
Improve the unit test coverage of pkg/cmd/server package (#6342)
Improve the unit test coverage of pkg/cmd/server package Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -36,6 +36,8 @@ import (
|
||||
clientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
|
||||
)
|
||||
|
||||
//go:generate mockery --name Factory
|
||||
|
||||
// Factory knows how to create a VeleroClient and Kubernetes client.
|
||||
type Factory interface {
|
||||
// BindFlags binds common flags (--kubeconfig, --namespace) to the passed-in FlagSet.
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
// Code generated by mockery v2.28.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
dynamic "k8s.io/client-go/dynamic"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
pflag "github.com/spf13/pflag"
|
||||
|
||||
pkgclient "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
rest "k8s.io/client-go/rest"
|
||||
|
||||
versioned "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
|
||||
)
|
||||
|
||||
// Factory is an autogenerated mock type for the Factory type
|
||||
type Factory struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// BindFlags provides a mock function with given fields: flags
|
||||
func (_m *Factory) BindFlags(flags *pflag.FlagSet) {
|
||||
_m.Called(flags)
|
||||
}
|
||||
|
||||
// Client provides a mock function with given fields:
|
||||
func (_m *Factory) Client() (versioned.Interface, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 versioned.Interface
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (versioned.Interface, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() versioned.Interface); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(versioned.Interface)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ClientConfig provides a mock function with given fields:
|
||||
func (_m *Factory) ClientConfig() (*rest.Config, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *rest.Config
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (*rest.Config, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() *rest.Config); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*rest.Config)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DynamicClient provides a mock function with given fields:
|
||||
func (_m *Factory) DynamicClient() (dynamic.Interface, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 dynamic.Interface
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (dynamic.Interface, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() dynamic.Interface); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(dynamic.Interface)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// KubeClient provides a mock function with given fields:
|
||||
func (_m *Factory) KubeClient() (kubernetes.Interface, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 kubernetes.Interface
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (kubernetes.Interface, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() kubernetes.Interface); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(kubernetes.Interface)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// KubebuilderClient provides a mock function with given fields:
|
||||
func (_m *Factory) KubebuilderClient() (pkgclient.Client, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 pkgclient.Client
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (pkgclient.Client, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() pkgclient.Client); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(pkgclient.Client)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Namespace provides a mock function with given fields:
|
||||
func (_m *Factory) Namespace() string {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// SetBasename provides a mock function with given fields: _a0
|
||||
func (_m *Factory) SetBasename(_a0 string) {
|
||||
_m.Called(_a0)
|
||||
}
|
||||
|
||||
// SetClientBurst provides a mock function with given fields: _a0
|
||||
func (_m *Factory) SetClientBurst(_a0 int) {
|
||||
_m.Called(_a0)
|
||||
}
|
||||
|
||||
// SetClientQPS provides a mock function with given fields: _a0
|
||||
func (_m *Factory) SetClientQPS(_a0 float32) {
|
||||
_m.Called(_a0)
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewFactory interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewFactory creates a new instance of Factory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewFactory(t mockConstructorTestingTNewFactory) *Factory {
|
||||
mock := &Factory{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
Reference in New Issue
Block a user