feat(mocks): add mock implementation of dashboard service
parent
c50284e0e2
commit
9f8a55f98e
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/influxdata/chronograf"
|
||||
platform "github.com/influxdata/chronograf/v2"
|
||||
)
|
||||
|
||||
var _ chronograf.DashboardsStore = &DashboardsStore{}
|
||||
|
@ -35,3 +36,33 @@ func (d *DashboardsStore) Get(ctx context.Context, id chronograf.DashboardID) (c
|
|||
func (d *DashboardsStore) Update(ctx context.Context, target chronograf.Dashboard) error {
|
||||
return d.UpdateF(ctx, target)
|
||||
}
|
||||
|
||||
var _ platform.DashboardService = &DashboardService{}
|
||||
|
||||
type DashboardService struct {
|
||||
CreateDashboardF func(context.Context, *platform.Dashboard) error
|
||||
FindDashboardByIDF func(context.Context, platform.ID) (*platform.Dashboard, error)
|
||||
FindDashboardsF func(context.Context, platform.DashboardFilter) ([]*platform.Dashboard, int, error)
|
||||
UpdateDashboardF func(context.Context, platform.ID, platform.DashboardUpdate) (*platform.Dashboard, error)
|
||||
DeleteDashboardF func(context.Context, platform.ID) error
|
||||
}
|
||||
|
||||
func (s *DashboardService) FindDashboardByID(ctx context.Context, id platform.ID) (*platform.Dashboard, error) {
|
||||
return s.FindDashboardByIDF(ctx, id)
|
||||
}
|
||||
|
||||
func (s *DashboardService) FindDashboards(ctx context.Context, filter platform.DashboardFilter) ([]*platform.Dashboard, int, error) {
|
||||
return s.FindDashboardsF(ctx, filter)
|
||||
}
|
||||
|
||||
func (s *DashboardService) CreateDashboard(ctx context.Context, b *platform.Dashboard) error {
|
||||
return s.CreateDashboardF(ctx, b)
|
||||
}
|
||||
|
||||
func (s *DashboardService) UpdateDashboard(ctx context.Context, id platform.ID, upd platform.DashboardUpdate) (*platform.Dashboard, error) {
|
||||
return s.UpdateDashboardF(ctx, id, upd)
|
||||
}
|
||||
|
||||
func (s *DashboardService) DeleteDashboard(ctx context.Context, id platform.ID) error {
|
||||
return s.DeleteDashboardF(ctx, id)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ type Store struct {
|
|||
ConfigStore chronograf.ConfigStore
|
||||
OrganizationConfigStore chronograf.OrganizationConfigStore
|
||||
CellService platform.CellService
|
||||
DashboardService platform.DashboardService
|
||||
}
|
||||
|
||||
func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore {
|
||||
|
@ -59,3 +60,7 @@ func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationC
|
|||
func (s *Store) Cells(ctx context.Context) platform.CellService {
|
||||
return s.CellService
|
||||
}
|
||||
|
||||
func (s *Store) DashboardsV2(ctx context.Context) platform.DashboardService {
|
||||
return s.DashboardService
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue