mirror of https://github.com/grafana/grafana
chore: replace artisanal FakeDashboardService with generated mock (#49276)
* chore: replace handmade FakeDashboardService with generated mock Maintaining a handcrafted FakeDashboardService is not sustainable now that we are in the process of moving the dashboard-related functions out of sqlstore. * remove dialect global variablepull/49428/head
parent
ccd160a75e
commit
8c753999df
@ -1,79 +1,263 @@ |
||||
// Code generated by mockery v2.12.2. DO NOT EDIT.
|
||||
|
||||
package dashboards |
||||
|
||||
import ( |
||||
"context" |
||||
context "context" |
||||
|
||||
models "github.com/grafana/grafana/pkg/models" |
||||
mock "github.com/stretchr/testify/mock" |
||||
|
||||
"github.com/grafana/grafana/pkg/models" |
||||
testing "testing" |
||||
) |
||||
|
||||
// FakeDashboardService is an autogenerated mock type for the DashboardService type
|
||||
type FakeDashboardService struct { |
||||
DashboardService |
||||
mock.Mock |
||||
} |
||||
|
||||
// BuildSaveDashboardCommand provides a mock function with given fields: ctx, dto, shouldValidateAlerts, validateProvisionedDashboard
|
||||
func (_m *FakeDashboardService) BuildSaveDashboardCommand(ctx context.Context, dto *SaveDashboardDTO, shouldValidateAlerts bool, validateProvisionedDashboard bool) (*models.SaveDashboardCommand, error) { |
||||
ret := _m.Called(ctx, dto, shouldValidateAlerts, validateProvisionedDashboard) |
||||
|
||||
SaveDashboardResult *models.Dashboard |
||||
SavedDashboards []*SaveDashboardDTO |
||||
ProvisionedDashData *models.DashboardProvisioning |
||||
var r0 *models.SaveDashboardCommand |
||||
if rf, ok := ret.Get(0).(func(context.Context, *SaveDashboardDTO, bool, bool) *models.SaveDashboardCommand); ok { |
||||
r0 = rf(ctx, dto, shouldValidateAlerts, validateProvisionedDashboard) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).(*models.SaveDashboardCommand) |
||||
} |
||||
} |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, *SaveDashboardDTO, bool, bool) error); ok { |
||||
r1 = rf(ctx, dto, shouldValidateAlerts, validateProvisionedDashboard) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
|
||||
PublicDashboardConfigResult *models.PublicDashboardConfig |
||||
PublicDashboardConfigError error |
||||
SaveDashboardError error |
||||
GetDashboardFn func(ctx context.Context, cmd *models.GetDashboardQuery) error |
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) { |
||||
s.SavedDashboards = append(s.SavedDashboards, dto) |
||||
// DeleteDashboard provides a mock function with given fields: ctx, dashboardId, orgId
|
||||
func (_m *FakeDashboardService) DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error { |
||||
ret := _m.Called(ctx, dashboardId, orgId) |
||||
|
||||
if s.SaveDashboardResult == nil && s.SaveDashboardError == nil { |
||||
s.SaveDashboardResult = dto.Dashboard |
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, int64) error); ok { |
||||
r0 = rf(ctx, dashboardId, orgId) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return s.SaveDashboardResult, s.SaveDashboardError |
||||
return r0 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) GetPublicDashboardConfig(ctx context.Context, orgId int64, dashboardUid string) (*models.PublicDashboardConfig, error) { |
||||
return s.PublicDashboardConfigResult, s.PublicDashboardConfigError |
||||
// FindDashboards provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeDashboardService) FindDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) ([]DashboardSearchProjection, error) { |
||||
ret := _m.Called(ctx, query) |
||||
|
||||
var r0 []DashboardSearchProjection |
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.FindPersistedDashboardsQuery) []DashboardSearchProjection); ok { |
||||
r0 = rf(ctx, query) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).([]DashboardSearchProjection) |
||||
} |
||||
} |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, *models.FindPersistedDashboardsQuery) error); ok { |
||||
r1 = rf(ctx, query) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
|
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) SavePublicDashboardConfig(ctx context.Context, dto *SavePublicDashboardConfigDTO) (*models.PublicDashboardConfig, error) { |
||||
return s.PublicDashboardConfigResult, s.PublicDashboardConfigError |
||||
// GetDashboard provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeDashboardService) GetDashboard(ctx context.Context, query *models.GetDashboardQuery) error { |
||||
ret := _m.Called(ctx, query) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.GetDashboardQuery) error); ok { |
||||
r0 = rf(ctx, query) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
|
||||
// GetDashboardUIDById provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeDashboardService) GetDashboardUIDById(ctx context.Context, query *models.GetDashboardRefByIdQuery) error { |
||||
ret := _m.Called(ctx, query) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.GetDashboardRefByIdQuery) error); ok { |
||||
r0 = rf(ctx, query) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*models.Dashboard, error) { |
||||
return s.SaveDashboard(ctx, dto, true) |
||||
// GetDashboards provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeDashboardService) GetDashboards(ctx context.Context, query *models.GetDashboardsQuery) error { |
||||
ret := _m.Called(ctx, query) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.GetDashboardsQuery) error); ok { |
||||
r0 = rf(ctx, query) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
|
||||
// GetPublicDashboardConfig provides a mock function with given fields: ctx, orgId, dashboardUid
|
||||
func (_m *FakeDashboardService) GetPublicDashboardConfig(ctx context.Context, orgId int64, dashboardUid string) (*models.PublicDashboardConfig, error) { |
||||
ret := _m.Called(ctx, orgId, dashboardUid) |
||||
|
||||
var r0 *models.PublicDashboardConfig |
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, string) *models.PublicDashboardConfig); ok { |
||||
r0 = rf(ctx, orgId, dashboardUid) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).(*models.PublicDashboardConfig) |
||||
} |
||||
} |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok { |
||||
r1 = rf(ctx, orgId, dashboardUid) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
|
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error { |
||||
for index, dash := range s.SavedDashboards { |
||||
if dash.Dashboard.Id == dashboardId && dash.OrgId == orgId { |
||||
s.SavedDashboards = append(s.SavedDashboards[:index], s.SavedDashboards[index+1:]...) |
||||
break |
||||
// ImportDashboard provides a mock function with given fields: ctx, dto
|
||||
func (_m *FakeDashboardService) ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*models.Dashboard, error) { |
||||
ret := _m.Called(ctx, dto) |
||||
|
||||
var r0 *models.Dashboard |
||||
if rf, ok := ret.Get(0).(func(context.Context, *SaveDashboardDTO) *models.Dashboard); ok { |
||||
r0 = rf(ctx, dto) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).(*models.Dashboard) |
||||
} |
||||
} |
||||
return nil |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, *SaveDashboardDTO) error); ok { |
||||
r1 = rf(ctx, dto) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
|
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) GetProvisionedDashboardDataByDashboardID(id int64) (*models.DashboardProvisioning, error) { |
||||
return s.ProvisionedDashData, nil |
||||
// MakeUserAdmin provides a mock function with given fields: ctx, orgID, userID, dashboardID, setViewAndEditPermissions
|
||||
func (_m *FakeDashboardService) MakeUserAdmin(ctx context.Context, orgID int64, userID int64, dashboardID int64, setViewAndEditPermissions bool) error { |
||||
ret := _m.Called(ctx, orgID, userID, dashboardID, setViewAndEditPermissions) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, int64, int64, bool) error); ok { |
||||
r0 = rf(ctx, orgID, userID, dashboardID, setViewAndEditPermissions) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
func (s *FakeDashboardService) DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *models.DeleteOrphanedProvisionedDashboardsCommand) error { |
||||
return nil |
||||
|
||||
// SaveDashboard provides a mock function with given fields: ctx, dto, allowUiUpdate
|
||||
func (_m *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) { |
||||
ret := _m.Called(ctx, dto, allowUiUpdate) |
||||
|
||||
var r0 *models.Dashboard |
||||
if rf, ok := ret.Get(0).(func(context.Context, *SaveDashboardDTO, bool) *models.Dashboard); ok { |
||||
r0 = rf(ctx, dto, allowUiUpdate) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).(*models.Dashboard) |
||||
} |
||||
} |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, *SaveDashboardDTO, bool) error); ok { |
||||
r1 = rf(ctx, dto, allowUiUpdate) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
|
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) GetDashboard(ctx context.Context, cmd *models.GetDashboardQuery) error { |
||||
if s.GetDashboardFn != nil { |
||||
return s.GetDashboardFn(ctx, cmd) |
||||
// SavePublicDashboardConfig provides a mock function with given fields: ctx, dto
|
||||
func (_m *FakeDashboardService) SavePublicDashboardConfig(ctx context.Context, dto *SavePublicDashboardConfigDTO) (*models.PublicDashboardConfig, error) { |
||||
ret := _m.Called(ctx, dto) |
||||
|
||||
var r0 *models.PublicDashboardConfig |
||||
if rf, ok := ret.Get(0).(func(context.Context, *SavePublicDashboardConfigDTO) *models.PublicDashboardConfig); ok { |
||||
r0 = rf(ctx, dto) |
||||
} else { |
||||
if ret.Get(0) != nil { |
||||
r0 = ret.Get(0).(*models.PublicDashboardConfig) |
||||
} |
||||
} |
||||
|
||||
var r1 error |
||||
if rf, ok := ret.Get(1).(func(context.Context, *SavePublicDashboardConfigDTO) error); ok { |
||||
r1 = rf(ctx, dto) |
||||
} else { |
||||
r1 = ret.Error(1) |
||||
} |
||||
// A minimal result for tests that need a valid result, but don't care what's in it.
|
||||
d := models.NewDashboard("mocked") |
||||
d.Id = 1 |
||||
d.Uid = "1" |
||||
cmd.Result = d |
||||
return nil |
||||
|
||||
return r0, r1 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) GetDashboardUIDById(ctx context.Context, query *models.GetDashboardRefByIdQuery) error { |
||||
return nil |
||||
// SearchDashboards provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeDashboardService) SearchDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) error { |
||||
ret := _m.Called(ctx, query) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.FindPersistedDashboardsQuery) error); ok { |
||||
r0 = rf(ctx, query) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
|
||||
func (s *FakeDashboardService) GetDashboards(ctx context.Context, query *models.GetDashboardsQuery) error { |
||||
return nil |
||||
// UpdateDashboardACL provides a mock function with given fields: ctx, uid, items
|
||||
func (_m *FakeDashboardService) UpdateDashboardACL(ctx context.Context, uid int64, items []*models.DashboardAcl) error { |
||||
ret := _m.Called(ctx, uid, items) |
||||
|
||||
var r0 error |
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, []*models.DashboardAcl) error); ok { |
||||
r0 = rf(ctx, uid, items) |
||||
} else { |
||||
r0 = ret.Error(0) |
||||
} |
||||
|
||||
return r0 |
||||
} |
||||
|
||||
// NewFakeDashboardService creates a new instance of FakeDashboardService. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewFakeDashboardService(t testing.TB) *FakeDashboardService { |
||||
mock := &FakeDashboardService{} |
||||
mock.Mock.Test(t) |
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) }) |
||||
|
||||
return mock |
||||
} |
||||
|
Loading…
Reference in new issue