2019-04-25 02:06:44 -05:00
|
|
|
package dashboards
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// Calls is a mock implementation of the provisioner interface
|
|
|
|
type calls struct {
|
2019-10-31 08:27:31 -05:00
|
|
|
Provision []interface{}
|
|
|
|
PollChanges []interface{}
|
|
|
|
GetProvisionerResolvedPath []interface{}
|
2020-04-15 01:12:52 -05:00
|
|
|
GetAllowUIUpdatesFromConfig []interface{}
|
2019-04-25 02:06:44 -05:00
|
|
|
}
|
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// ProvisionerMock is a mock implementation of `Provisioner`
|
|
|
|
type ProvisionerMock struct {
|
|
|
|
Calls *calls
|
2019-10-31 08:27:31 -05:00
|
|
|
ProvisionFunc func() error
|
|
|
|
PollChangesFunc func(ctx context.Context)
|
|
|
|
GetProvisionerResolvedPathFunc func(name string) string
|
2020-04-15 01:12:52 -05:00
|
|
|
GetAllowUIUpdatesFromConfigFunc func(name string) bool
|
2019-04-25 02:06:44 -05:00
|
|
|
}
|
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// NewDashboardProvisionerMock returns a new dashboardprovisionermock
|
|
|
|
func NewDashboardProvisionerMock() *ProvisionerMock {
|
|
|
|
return &ProvisionerMock{
|
|
|
|
Calls: &calls{},
|
2019-04-25 02:06:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// Provision is a mock implementation of `Provisioner.Provision`
|
|
|
|
func (dpm *ProvisionerMock) Provision() error {
|
2019-04-25 02:06:44 -05:00
|
|
|
dpm.Calls.Provision = append(dpm.Calls.Provision, nil)
|
|
|
|
if dpm.ProvisionFunc != nil {
|
|
|
|
return dpm.ProvisionFunc()
|
|
|
|
}
|
2019-05-15 16:29:26 -05:00
|
|
|
return nil
|
2019-04-25 02:06:44 -05:00
|
|
|
}
|
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// PollChanges is a mock implementation of `Provisioner.PollChanges`
|
|
|
|
func (dpm *ProvisionerMock) PollChanges(ctx context.Context) {
|
2019-04-25 02:06:44 -05:00
|
|
|
dpm.Calls.PollChanges = append(dpm.Calls.PollChanges, ctx)
|
|
|
|
if dpm.PollChangesFunc != nil {
|
|
|
|
dpm.PollChangesFunc(ctx)
|
|
|
|
}
|
|
|
|
}
|
2019-04-30 06:32:18 -05:00
|
|
|
|
2020-04-15 01:12:52 -05:00
|
|
|
// GetProvisionerResolvedPath is a mock implementation of `Provisioner.GetProvisionerResolvedPath`
|
|
|
|
func (dpm *ProvisionerMock) GetProvisionerResolvedPath(name string) string {
|
2019-10-31 08:27:31 -05:00
|
|
|
dpm.Calls.GetProvisionerResolvedPath = append(dpm.Calls.GetProvisionerResolvedPath, name)
|
2019-04-30 06:32:18 -05:00
|
|
|
if dpm.GetProvisionerResolvedPathFunc != nil {
|
|
|
|
return dpm.GetProvisionerResolvedPathFunc(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
|
|
|
// GetAllowUIUpdatesFromConfig is a mock implementation of `Provisioner.GetAllowUIUpdatesFromConfig`
|
|
|
|
func (dpm *ProvisionerMock) GetAllowUIUpdatesFromConfig(name string) bool {
|
|
|
|
dpm.Calls.GetAllowUIUpdatesFromConfig = append(dpm.Calls.GetAllowUIUpdatesFromConfig, name)
|
|
|
|
if dpm.GetAllowUIUpdatesFromConfigFunc != nil {
|
|
|
|
return dpm.GetAllowUIUpdatesFromConfigFunc(name)
|
2019-10-31 08:27:31 -05:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|