test(mocks): add mock cell service

pull/3842/head
Michael Desa 2018-07-09 15:37:59 -07:00
parent 4ba1dba579
commit f3f722d987
2 changed files with 43 additions and 0 deletions

37
mocks/cells.go Normal file
View File

@ -0,0 +1,37 @@
package mocks
import (
"context"
chronograf "github.com/influxdata/chronograf/v2"
)
var _ chronograf.CellService = &CellService{}
type CellService struct {
CreateCellF func(context.Context, *chronograf.Cell) error
FindCellByIDF func(context.Context, chronograf.ID) (*chronograf.Cell, error)
FindCellsF func(context.Context, chronograf.CellFilter) ([]*chronograf.Cell, int, error)
UpdateCellF func(context.Context, chronograf.ID, chronograf.CellUpdate) (*chronograf.Cell, error)
DeleteCellF func(context.Context, chronograf.ID) error
}
func (s *CellService) FindCellByID(ctx context.Context, id chronograf.ID) (*chronograf.Cell, error) {
return s.FindCellByIDF(ctx, id)
}
func (s *CellService) FindCells(ctx context.Context, filter chronograf.CellFilter) ([]*chronograf.Cell, int, error) {
return s.FindCellsF(ctx, filter)
}
func (s *CellService) CreateCell(ctx context.Context, b *chronograf.Cell) error {
return s.CreateCellF(ctx, b)
}
func (s *CellService) UpdateCell(ctx context.Context, id chronograf.ID, upd chronograf.CellUpdate) (*chronograf.Cell, error) {
return s.UpdateCellF(ctx, id, upd)
}
func (s *CellService) DeleteCell(ctx context.Context, id chronograf.ID) error {
return s.DeleteCellF(ctx, id)
}

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/influxdata/chronograf"
chronografv2 "github.com/influxdata/chronograf/v2"
)
// Store is a server.DataStore
@ -17,6 +18,7 @@ type Store struct {
OrganizationsStore chronograf.OrganizationsStore
ConfigStore chronograf.ConfigStore
OrganizationConfigStore chronograf.OrganizationConfigStore
CellService chronografv2.CellService
}
func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore {
@ -53,3 +55,7 @@ func (s *Store) Config(ctx context.Context) chronograf.ConfigStore {
func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore {
return s.OrganizationConfigStore
}
func (s *Store) Cells(ctx context.Context) chronografv2.CellService {
return s.CellService
}