mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 02:42:09 +08:00

* Add repository resources interface for export worker * Add mocks for repository resources * Add unit tests for ExportWorker's IsSupported method * Add unit tests for ExportWorker's Process method, covering scenarios for missing export settings, write permissions, branch restrictions, and client creation failures. * Fix unit tests * Single function * Add more unit tests * Add test for failed folder * Fail export folder errors * Add another test * Positive folder export * Too many folder export errors * Too many errors on folder export * Partial folder errors * Add test for nested folder * Add test dashboard export * More cases * Ignore existing dashboards * Fix folder tests * Fix clonable test * Add clone failure test * Add test clean up without push * Working tests * Use mock clonable * Add unit tests for IsWriteAllowed * Add behaviour to cover ref equal to configured branch * Fix worker test * Fix linting * Split clone and push * Wrapper for clone and push
311 lines
8.1 KiB
Go
311 lines
8.1 KiB
Go
// Code generated by mockery v2.52.4. DO NOT EDIT.
|
|
|
|
package repository
|
|
|
|
import (
|
|
context "context"
|
|
|
|
mock "github.com/stretchr/testify/mock"
|
|
field "k8s.io/apimachinery/pkg/util/validation/field"
|
|
|
|
v0alpha1 "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
|
)
|
|
|
|
// MockReader is an autogenerated mock type for the Reader type
|
|
type MockReader struct {
|
|
mock.Mock
|
|
}
|
|
|
|
type MockReader_Expecter struct {
|
|
mock *mock.Mock
|
|
}
|
|
|
|
func (_m *MockReader) EXPECT() *MockReader_Expecter {
|
|
return &MockReader_Expecter{mock: &_m.Mock}
|
|
}
|
|
|
|
// Config provides a mock function with no fields
|
|
func (_m *MockReader) Config() *v0alpha1.Repository {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Config")
|
|
}
|
|
|
|
var r0 *v0alpha1.Repository
|
|
if rf, ok := ret.Get(0).(func() *v0alpha1.Repository); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(*v0alpha1.Repository)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// MockReader_Config_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Config'
|
|
type MockReader_Config_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Config is a helper method to define mock.On call
|
|
func (_e *MockReader_Expecter) Config() *MockReader_Config_Call {
|
|
return &MockReader_Config_Call{Call: _e.mock.On("Config")}
|
|
}
|
|
|
|
func (_c *MockReader_Config_Call) Run(run func()) *MockReader_Config_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Config_Call) Return(_a0 *v0alpha1.Repository) *MockReader_Config_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Config_Call) RunAndReturn(run func() *v0alpha1.Repository) *MockReader_Config_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Read provides a mock function with given fields: ctx, path, ref
|
|
func (_m *MockReader) Read(ctx context.Context, path string, ref string) (*FileInfo, error) {
|
|
ret := _m.Called(ctx, path, ref)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Read")
|
|
}
|
|
|
|
var r0 *FileInfo
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, string, string) (*FileInfo, error)); ok {
|
|
return rf(ctx, path, ref)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, string, string) *FileInfo); ok {
|
|
r0 = rf(ctx, path, ref)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(*FileInfo)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
|
r1 = rf(ctx, path, ref)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// MockReader_Read_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Read'
|
|
type MockReader_Read_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Read is a helper method to define mock.On call
|
|
// - ctx context.Context
|
|
// - path string
|
|
// - ref string
|
|
func (_e *MockReader_Expecter) Read(ctx interface{}, path interface{}, ref interface{}) *MockReader_Read_Call {
|
|
return &MockReader_Read_Call{Call: _e.mock.On("Read", ctx, path, ref)}
|
|
}
|
|
|
|
func (_c *MockReader_Read_Call) Run(run func(ctx context.Context, path string, ref string)) *MockReader_Read_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(context.Context), args[1].(string), args[2].(string))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Read_Call) Return(_a0 *FileInfo, _a1 error) *MockReader_Read_Call {
|
|
_c.Call.Return(_a0, _a1)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Read_Call) RunAndReturn(run func(context.Context, string, string) (*FileInfo, error)) *MockReader_Read_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// ReadTree provides a mock function with given fields: ctx, ref
|
|
func (_m *MockReader) ReadTree(ctx context.Context, ref string) ([]FileTreeEntry, error) {
|
|
ret := _m.Called(ctx, ref)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for ReadTree")
|
|
}
|
|
|
|
var r0 []FileTreeEntry
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, string) ([]FileTreeEntry, error)); ok {
|
|
return rf(ctx, ref)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, string) []FileTreeEntry); ok {
|
|
r0 = rf(ctx, ref)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).([]FileTreeEntry)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
|
r1 = rf(ctx, ref)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// MockReader_ReadTree_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadTree'
|
|
type MockReader_ReadTree_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// ReadTree is a helper method to define mock.On call
|
|
// - ctx context.Context
|
|
// - ref string
|
|
func (_e *MockReader_Expecter) ReadTree(ctx interface{}, ref interface{}) *MockReader_ReadTree_Call {
|
|
return &MockReader_ReadTree_Call{Call: _e.mock.On("ReadTree", ctx, ref)}
|
|
}
|
|
|
|
func (_c *MockReader_ReadTree_Call) Run(run func(ctx context.Context, ref string)) *MockReader_ReadTree_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(context.Context), args[1].(string))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_ReadTree_Call) Return(_a0 []FileTreeEntry, _a1 error) *MockReader_ReadTree_Call {
|
|
_c.Call.Return(_a0, _a1)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_ReadTree_Call) RunAndReturn(run func(context.Context, string) ([]FileTreeEntry, error)) *MockReader_ReadTree_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Test provides a mock function with given fields: ctx
|
|
func (_m *MockReader) Test(ctx context.Context) (*v0alpha1.TestResults, error) {
|
|
ret := _m.Called(ctx)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Test")
|
|
}
|
|
|
|
var r0 *v0alpha1.TestResults
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context) (*v0alpha1.TestResults, error)); ok {
|
|
return rf(ctx)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context) *v0alpha1.TestResults); ok {
|
|
r0 = rf(ctx)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(*v0alpha1.TestResults)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
|
r1 = rf(ctx)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// MockReader_Test_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Test'
|
|
type MockReader_Test_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Test is a helper method to define mock.On call
|
|
// - ctx context.Context
|
|
func (_e *MockReader_Expecter) Test(ctx interface{}) *MockReader_Test_Call {
|
|
return &MockReader_Test_Call{Call: _e.mock.On("Test", ctx)}
|
|
}
|
|
|
|
func (_c *MockReader_Test_Call) Run(run func(ctx context.Context)) *MockReader_Test_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(context.Context))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Test_Call) Return(_a0 *v0alpha1.TestResults, _a1 error) *MockReader_Test_Call {
|
|
_c.Call.Return(_a0, _a1)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Test_Call) RunAndReturn(run func(context.Context) (*v0alpha1.TestResults, error)) *MockReader_Test_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// Validate provides a mock function with no fields
|
|
func (_m *MockReader) Validate() field.ErrorList {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Validate")
|
|
}
|
|
|
|
var r0 field.ErrorList
|
|
if rf, ok := ret.Get(0).(func() field.ErrorList); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(field.ErrorList)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// MockReader_Validate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Validate'
|
|
type MockReader_Validate_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Validate is a helper method to define mock.On call
|
|
func (_e *MockReader_Expecter) Validate() *MockReader_Validate_Call {
|
|
return &MockReader_Validate_Call{Call: _e.mock.On("Validate")}
|
|
}
|
|
|
|
func (_c *MockReader_Validate_Call) Run(run func()) *MockReader_Validate_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run()
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Validate_Call) Return(_a0 field.ErrorList) *MockReader_Validate_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockReader_Validate_Call) RunAndReturn(run func() field.ErrorList) *MockReader_Validate_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// NewMockReader creates a new instance of MockReader. 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 NewMockReader(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}) *MockReader {
|
|
mock := &MockReader{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|