grafana/pkg/services/provisioning/provisioning_mock.go
Jon Gyllenswärd a45ce36566
Allow saving of provisioned dashboards (#19820)
Allows saving of provisioned dashboards if the config value allowUiUpdates is set to true

Fixes #11778
2019-10-31 14:27:31 +01:00

65 lines
2.1 KiB
Go

package provisioning
type Calls struct {
ProvisionDatasources []interface{}
ProvisionNotifications []interface{}
ProvisionDashboards []interface{}
GetDashboardProvisionerResolvedPath []interface{}
GetAllowUiUpdatesFromConfig []interface{}
}
type ProvisioningServiceMock struct {
Calls *Calls
ProvisionDatasourcesFunc func() error
ProvisionNotificationsFunc func() error
ProvisionDashboardsFunc func() error
GetDashboardProvisionerResolvedPathFunc func(name string) string
GetAllowUiUpdatesFromConfigFunc func(name string) bool
}
func NewProvisioningServiceMock() *ProvisioningServiceMock {
return &ProvisioningServiceMock{
Calls: &Calls{},
}
}
func (mock *ProvisioningServiceMock) ProvisionDatasources() error {
mock.Calls.ProvisionDatasources = append(mock.Calls.ProvisionDatasources, nil)
if mock.ProvisionDatasourcesFunc != nil {
return mock.ProvisionDatasourcesFunc()
}
return nil
}
func (mock *ProvisioningServiceMock) ProvisionNotifications() error {
mock.Calls.ProvisionNotifications = append(mock.Calls.ProvisionNotifications, nil)
if mock.ProvisionNotificationsFunc != nil {
return mock.ProvisionNotificationsFunc()
}
return nil
}
func (mock *ProvisioningServiceMock) ProvisionDashboards() error {
mock.Calls.ProvisionDashboards = append(mock.Calls.ProvisionDashboards, nil)
if mock.ProvisionDashboardsFunc != nil {
return mock.ProvisionDashboardsFunc()
}
return nil
}
func (mock *ProvisioningServiceMock) GetDashboardProvisionerResolvedPath(name string) string {
mock.Calls.GetDashboardProvisionerResolvedPath = append(mock.Calls.GetDashboardProvisionerResolvedPath, name)
if mock.GetDashboardProvisionerResolvedPathFunc != nil {
return mock.GetDashboardProvisionerResolvedPathFunc(name)
}
return ""
}
func (mock *ProvisioningServiceMock) GetAllowUiUpdatesFromConfig(name string) bool {
mock.Calls.GetAllowUiUpdatesFromConfig = append(mock.Calls.GetAllowUiUpdatesFromConfig, name)
if mock.GetAllowUiUpdatesFromConfigFunc != nil {
return mock.GetAllowUiUpdatesFromConfigFunc(name)
}
return false
}