mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* make getordbyname a method * remove one dispatch from plugins provisioner * remove bus from the plugins provisioner, skip test for now * remove bus from datasource provisioning * resolve tests in notifier provisioning * remove bus from the dashboards provisioning service * fix missing struct field * fix getorgbyid method calls * pass org store into dashboard provisioner * fix test function prototype * fix tests * attempt to fix tests after the rebase * fix integration test * avoid using transaction * remove comments
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package dashboards
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type FakeDashboardService struct {
|
|
DashboardService
|
|
|
|
SaveDashboardResult *models.Dashboard
|
|
SaveDashboardError error
|
|
SavedDashboards []*SaveDashboardDTO
|
|
ProvisionedDashData *models.DashboardProvisioning
|
|
}
|
|
|
|
func (s *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) {
|
|
s.SavedDashboards = append(s.SavedDashboards, dto)
|
|
|
|
if s.SaveDashboardResult == nil && s.SaveDashboardError == nil {
|
|
s.SaveDashboardResult = dto.Dashboard
|
|
}
|
|
|
|
return s.SaveDashboardResult, s.SaveDashboardError
|
|
}
|
|
|
|
func (s *FakeDashboardService) ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*models.Dashboard, error) {
|
|
return s.SaveDashboard(ctx, dto, true)
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *FakeDashboardService) GetProvisionedDashboardDataByDashboardID(id int64) (*models.DashboardProvisioning, error) {
|
|
return s.ProvisionedDashData, nil
|
|
}
|
|
func (s *FakeDashboardService) DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *models.DeleteOrphanedProvisionedDashboardsCommand) error {
|
|
return nil
|
|
}
|