2019-04-30 06:32:18 -05:00
|
|
|
package provisioning
|
|
|
|
|
2023-08-03 08:19:01 -05:00
|
|
|
import "context"
|
2021-04-21 06:41:34 -05:00
|
|
|
|
2019-04-30 06:32:18 -05:00
|
|
|
type Calls struct {
|
2023-08-30 10:46:47 -05:00
|
|
|
RunInitProvisioners []any
|
|
|
|
ProvisionDatasources []any
|
|
|
|
ProvisionPlugins []any
|
|
|
|
ProvisionNotifications []any
|
|
|
|
ProvisionDashboards []any
|
|
|
|
ProvisionAlerting []any
|
|
|
|
GetDashboardProvisionerResolvedPath []any
|
|
|
|
GetAllowUIUpdatesFromConfig []any
|
|
|
|
Run []any
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProvisioningServiceMock struct {
|
|
|
|
Calls *Calls
|
2021-10-18 10:06:19 -05:00
|
|
|
RunInitProvisionersFunc func(ctx context.Context) error
|
|
|
|
ProvisionDatasourcesFunc func(ctx context.Context) error
|
2020-06-22 10:49:13 -05:00
|
|
|
ProvisionPluginsFunc func() error
|
2019-04-30 06:32:18 -05:00
|
|
|
ProvisionNotificationsFunc func() error
|
|
|
|
ProvisionDashboardsFunc func() error
|
|
|
|
GetDashboardProvisionerResolvedPathFunc func(name string) string
|
2020-04-15 01:12:52 -05:00
|
|
|
GetAllowUIUpdatesFromConfigFunc func(name string) bool
|
2021-04-21 06:41:34 -05:00
|
|
|
RunFunc func(ctx context.Context) error
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
|
|
|
|
2021-11-03 05:31:56 -05:00
|
|
|
func NewProvisioningServiceMock(ctx context.Context) *ProvisioningServiceMock {
|
2023-08-03 08:19:01 -05:00
|
|
|
return &ProvisioningServiceMock{
|
2019-04-30 06:32:18 -05:00
|
|
|
Calls: &Calls{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:06:19 -05:00
|
|
|
func (mock *ProvisioningServiceMock) RunInitProvisioners(ctx context.Context) error {
|
2021-04-21 06:41:34 -05:00
|
|
|
mock.Calls.RunInitProvisioners = append(mock.Calls.RunInitProvisioners, nil)
|
|
|
|
if mock.RunInitProvisionersFunc != nil {
|
2021-10-18 10:06:19 -05:00
|
|
|
return mock.RunInitProvisionersFunc(ctx)
|
2021-04-21 06:41:34 -05:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:06:19 -05:00
|
|
|
func (mock *ProvisioningServiceMock) ProvisionDatasources(ctx context.Context) error {
|
2019-04-30 06:32:18 -05:00
|
|
|
mock.Calls.ProvisionDatasources = append(mock.Calls.ProvisionDatasources, nil)
|
|
|
|
if mock.ProvisionDatasourcesFunc != nil {
|
2021-10-18 10:06:19 -05:00
|
|
|
return mock.ProvisionDatasourcesFunc(ctx)
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
2019-05-15 16:29:26 -05:00
|
|
|
return nil
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
|
|
|
|
2021-12-02 11:08:59 -06:00
|
|
|
func (mock *ProvisioningServiceMock) ProvisionPlugins(ctx context.Context) error {
|
2020-06-22 10:49:13 -05:00
|
|
|
mock.Calls.ProvisionPlugins = append(mock.Calls.ProvisionPlugins, nil)
|
|
|
|
if mock.ProvisionPluginsFunc != nil {
|
|
|
|
return mock.ProvisionPluginsFunc()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-11-03 05:31:56 -05:00
|
|
|
func (mock *ProvisioningServiceMock) ProvisionNotifications(ctx context.Context) error {
|
2019-04-30 06:32:18 -05:00
|
|
|
mock.Calls.ProvisionNotifications = append(mock.Calls.ProvisionNotifications, nil)
|
|
|
|
if mock.ProvisionNotificationsFunc != nil {
|
|
|
|
return mock.ProvisionNotificationsFunc()
|
|
|
|
}
|
2019-05-15 16:29:26 -05:00
|
|
|
return nil
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
|
|
|
|
2021-10-05 06:26:24 -05:00
|
|
|
func (mock *ProvisioningServiceMock) ProvisionDashboards(ctx context.Context) error {
|
2019-04-30 06:32:18 -05:00
|
|
|
mock.Calls.ProvisionDashboards = append(mock.Calls.ProvisionDashboards, nil)
|
|
|
|
if mock.ProvisionDashboardsFunc != nil {
|
|
|
|
return mock.ProvisionDashboardsFunc()
|
|
|
|
}
|
2019-05-15 16:29:26 -05:00
|
|
|
return nil
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
|
|
|
|
2022-08-01 11:17:42 -05:00
|
|
|
func (mock *ProvisioningServiceMock) ProvisionAlerting(ctx context.Context) error {
|
|
|
|
mock.Calls.ProvisionAlerting = append(mock.Calls.ProvisionAlerting, nil)
|
2022-07-14 16:53:13 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-30 06:32:18 -05:00
|
|
|
func (mock *ProvisioningServiceMock) GetDashboardProvisionerResolvedPath(name string) string {
|
|
|
|
mock.Calls.GetDashboardProvisionerResolvedPath = append(mock.Calls.GetDashboardProvisionerResolvedPath, name)
|
|
|
|
if mock.GetDashboardProvisionerResolvedPathFunc != nil {
|
|
|
|
return mock.GetDashboardProvisionerResolvedPathFunc(name)
|
|
|
|
}
|
2019-05-15 16:29:26 -05:00
|
|
|
return ""
|
2019-04-30 06:32:18 -05:00
|
|
|
}
|
2019-10-31 08:27:31 -05:00
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
func (mock *ProvisioningServiceMock) GetAllowUIUpdatesFromConfig(name string) bool {
|
|
|
|
mock.Calls.GetAllowUIUpdatesFromConfig = append(mock.Calls.GetAllowUIUpdatesFromConfig, name)
|
|
|
|
if mock.GetAllowUIUpdatesFromConfigFunc != nil {
|
|
|
|
return mock.GetAllowUIUpdatesFromConfigFunc(name)
|
2019-10-31 08:27:31 -05:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2021-04-21 06:41:34 -05:00
|
|
|
|
|
|
|
func (mock *ProvisioningServiceMock) Run(ctx context.Context) error {
|
|
|
|
mock.Calls.Run = append(mock.Calls.Run, nil)
|
|
|
|
if mock.RunFunc != nil {
|
|
|
|
return mock.RunFunc(ctx)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|