grafana/pkg/services/provisioning/dashboards/dashboard_mock.go
Oleg Gaidarenko be66ed9dab
Chore: explore possibilities of using makefile (#17039)
* Chore: explore possibilities of using makefile

This is an exploratory commit - I wanted to see how
revive/gosec linters could be integrated with makefile and our build scripts.

Looks better then I expected :)

* Chore: make revive happy

Revive execution was not supplied with path, if you restore there is couple
errors that were popping up - so I fixed them

* Chore: make revive happy
2019-05-16 00:29:26 +03:00

46 lines
1.2 KiB
Go

package dashboards
import "context"
type Calls struct {
Provision []interface{}
PollChanges []interface{}
GetProvisionerResolvedPath []interface{}
}
type DashboardProvisionerMock struct {
Calls *Calls
ProvisionFunc func() error
PollChangesFunc func(ctx context.Context)
GetProvisionerResolvedPathFunc func(name string) string
}
func NewDashboardProvisionerMock() *DashboardProvisionerMock {
return &DashboardProvisionerMock{
Calls: &Calls{},
}
}
func (dpm *DashboardProvisionerMock) Provision() error {
dpm.Calls.Provision = append(dpm.Calls.Provision, nil)
if dpm.ProvisionFunc != nil {
return dpm.ProvisionFunc()
}
return nil
}
func (dpm *DashboardProvisionerMock) PollChanges(ctx context.Context) {
dpm.Calls.PollChanges = append(dpm.Calls.PollChanges, ctx)
if dpm.PollChangesFunc != nil {
dpm.PollChangesFunc(ctx)
}
}
func (dpm *DashboardProvisionerMock) GetProvisionerResolvedPath(name string) string {
dpm.Calls.PollChanges = append(dpm.Calls.GetProvisionerResolvedPath, name)
if dpm.GetProvisionerResolvedPathFunc != nil {
return dpm.GetProvisionerResolvedPathFunc(name)
}
return ""
}