feat(mock): scraper service mock

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
pull/10616/head
Leonardo Di Donato 2019-01-07 12:27:38 +01:00 committed by Leonardo Di Donato
parent 14b5f103c4
commit c90f79d28a
2 changed files with 43 additions and 1 deletions

43
mock/scraper_service.go Normal file
View File

@ -0,0 +1,43 @@
package mock
import (
"context"
"github.com/influxdata/platform"
)
var _ platform.ScraperTargetStoreService = &ScraperTargetStoreService{}
// ScraperTargetStoreService is a mock implementation of a platform.ScraperTargetStoreService.
type ScraperTargetStoreService struct {
ListTargetsF func(ctx context.Context) ([]platform.ScraperTarget, error)
AddTargetF func(ctx context.Context, t *platform.ScraperTarget) error
GetTargetByIDF func(ctx context.Context, id platform.ID) (*platform.ScraperTarget, error)
RemoveTargetF func(ctx context.Context, id platform.ID) error
UpdateTargetF func(ctx context.Context, t *platform.ScraperTarget) (*platform.ScraperTarget, error)
}
// ListTargets lists all the scraper targets.
func (s *ScraperTargetStoreService) ListTargets(ctx context.Context) ([]platform.ScraperTarget, error) {
return s.ListTargetsF(ctx)
}
// AddTarget adds a scraper target.
func (s *ScraperTargetStoreService) AddTarget(ctx context.Context, t *platform.ScraperTarget) error {
return s.AddTargetF(ctx, t)
}
// GetTargetByID retrieves a scraper target by id.
func (s *ScraperTargetStoreService) GetTargetByID(ctx context.Context, id platform.ID) (*platform.ScraperTarget, error) {
return s.GetTargetByIDF(ctx, id)
}
// RemoveTarget deletes a scraper target.
func (s *ScraperTargetStoreService) RemoveTarget(ctx context.Context, id platform.ID) error {
return s.RemoveTargetF(ctx, id)
}
// UpdateTarget updates a scraper target.
func (s *ScraperTargetStoreService) UpdateTarget(ctx context.Context, t *platform.ScraperTarget) (*platform.ScraperTarget, error) {
return s.UpdateTargetF(ctx, t)
}

View File

@ -24,7 +24,6 @@ type TaskService struct {
func (s *TaskService) FindTaskByID(ctx context.Context, id platform.ID) (*platform.Task, error) { func (s *TaskService) FindTaskByID(ctx context.Context, id platform.ID) (*platform.Task, error) {
return s.FindTaskByIDFn(ctx, id) return s.FindTaskByIDFn(ctx, id)
} }
func (s *TaskService) FindTasks(ctx context.Context, filter platform.TaskFilter) ([]*platform.Task, int, error) { func (s *TaskService) FindTasks(ctx context.Context, filter platform.TaskFilter) ([]*platform.Task, int, error) {