mock

package
v0.0.0-...-f5b6858 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultConnProt = "tcp"
	DefaultConnHost = "localhost"
	DefaultBuffSize = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketService

type BucketService struct {
	// Methods for a retention.BucketService
	OpenFn       func() error
	CloseFn      func() error
	WithLoggerFn func(l *zap.Logger)

	// Methods for an platform.BucketService
	FindBucketByIDFn func(context.Context, platform.ID) (*platform.Bucket, error)
	FindBucketFn     func(context.Context, platform.BucketFilter) (*platform.Bucket, error)
	FindBucketsFn    func(context.Context, platform.BucketFilter, ...platform.FindOptions) ([]*platform.Bucket, int, error)
	CreateBucketFn   func(context.Context, *platform.Bucket) error
	UpdateBucketFn   func(context.Context, platform.ID, platform.BucketUpdate) (*platform.Bucket, error)
	DeleteBucketFn   func(context.Context, platform.ID) error
}

BucketService is a mock implementation of a retention.BucketService, which also makes it a suitable mock to use wherever an platform.BucketService is required.

func NewBucketService

func NewBucketService() *BucketService

NewBucketService returns a mock BucketService where its methods will return zero values.

func (*BucketService) Close

func (s *BucketService) Close() error

Close closes the BucketService.

func (*BucketService) CreateBucket

func (s *BucketService) CreateBucket(ctx context.Context, bucket *platform.Bucket) error

CreateBucket creates a new bucket and sets b.ID with the new identifier.

func (*BucketService) DeleteBucket

func (s *BucketService) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket removes a bucket by ID.

func (*BucketService) FindBucket

func (s *BucketService) FindBucket(ctx context.Context, filter platform.BucketFilter) (*platform.Bucket, error)

FindBucket returns the first bucket that matches filter.

func (*BucketService) FindBucketByID

func (s *BucketService) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketService) FindBuckets

func (s *BucketService) FindBuckets(ctx context.Context, filter platform.BucketFilter, opts ...platform.FindOptions) ([]*platform.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets.

func (*BucketService) Open

func (s *BucketService) Open() error

Open opens the BucketService.

func (*BucketService) UpdateBucket

func (s *BucketService) UpdateBucket(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error)

UpdateBucket updates a single bucket with changeset.

func (*BucketService) WithLogger

func (s *BucketService) WithLogger(l *zap.Logger)

WithLogger sets the logger on the BucketService.

type DBRPMappingService

type DBRPMappingService struct {
	FindByFn   func(ctx context.Context, cluster string, db string, rp string) (*platform.DBRPMapping, error)
	FindFn     func(ctx context.Context, filter platform.DBRPMappingFilter) (*platform.DBRPMapping, error)
	FindManyFn func(ctx context.Context, filter platform.DBRPMappingFilter, opt ...platform.FindOptions) ([]*platform.DBRPMapping, int, error)
	CreateFn   func(ctx context.Context, dbrpMap *platform.DBRPMapping) error
	DeleteFn   func(ctx context.Context, cluster string, db string, rp string) error
}

func NewDBRPMappingService

func NewDBRPMappingService() *DBRPMappingService

func (*DBRPMappingService) Create

func (s *DBRPMappingService) Create(ctx context.Context, dbrpMap *platform.DBRPMapping) error

func (*DBRPMappingService) Delete

func (s *DBRPMappingService) Delete(ctx context.Context, cluster string, db string, rp string) error

func (*DBRPMappingService) Find

func (s *DBRPMappingService) Find(ctx context.Context, filter platform.DBRPMappingFilter) (*platform.DBRPMapping, error)

func (*DBRPMappingService) FindBy

func (s *DBRPMappingService) FindBy(ctx context.Context, cluster string, db string, rp string) (*platform.DBRPMapping, error)

func (*DBRPMappingService) FindMany

func (s *DBRPMappingService) FindMany(ctx context.Context, filter platform.DBRPMappingFilter, opt ...platform.FindOptions) ([]*platform.DBRPMapping, int, error)

type 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

	AddDashboardCellF      func(ctx context.Context, id platform.ID, c *platform.Cell, opts platform.AddDashboardCellOptions) error
	RemoveDashboardCellF   func(ctx context.Context, dashboardID platform.ID, cellID platform.ID) error
	UpdateDashboardCellF   func(ctx context.Context, dashbaordID platform.ID, cellID platform.ID, upd platform.CellUpdate) (*platform.Cell, error)
	CopyDashboardCellF     func(ctx context.Context, dashbaordID platform.ID, cellID platform.ID) (*platform.Cell, error)
	ReplaceDashboardCellsF func(ctx context.Context, id platform.ID, cs []*platform.Cell) error
}

func (*DashboardService) AddDashboardCell

func (s *DashboardService) AddDashboardCell(ctx context.Context, id platform.ID, c *platform.Cell, opts platform.AddDashboardCellOptions) error

func (*DashboardService) CopyDashboardCell

func (s *DashboardService) CopyDashboardCell(ctx context.Context, dashboardID platform.ID, cellID platform.ID) (*platform.Cell, error)

func (*DashboardService) CreateDashboard

func (s *DashboardService) CreateDashboard(ctx context.Context, b *platform.Dashboard) error

func (*DashboardService) DeleteDashboard

func (s *DashboardService) DeleteDashboard(ctx context.Context, id platform.ID) error

func (*DashboardService) FindDashboardByID

func (s *DashboardService) FindDashboardByID(ctx context.Context, id platform.ID) (*platform.Dashboard, error)

func (*DashboardService) FindDashboards

func (s *DashboardService) FindDashboards(ctx context.Context, filter platform.DashboardFilter) ([]*platform.Dashboard, int, error)

func (*DashboardService) RemoveDashboardCell

func (s *DashboardService) RemoveDashboardCell(ctx context.Context, dashboardID platform.ID, cellID platform.ID) error

func (*DashboardService) ReplaceDashboardCells

func (s *DashboardService) ReplaceDashboardCells(ctx context.Context, id platform.ID, cs []*platform.Cell) error

func (*DashboardService) UpdateDashboard

func (s *DashboardService) UpdateDashboard(ctx context.Context, id platform.ID, upd platform.DashboardUpdate) (*platform.Dashboard, error)

func (*DashboardService) UpdateDashboardCell

func (s *DashboardService) UpdateDashboardCell(ctx context.Context, dashboardID platform.ID, cellID platform.ID, upd platform.CellUpdate) (*platform.Cell, error)

type IDGenerator

type IDGenerator struct {
	IDFn func() platform.ID
}

IDGenerator is mock implementation of platform.IDGenerator.

func NewIDGenerator

func NewIDGenerator(s string, t *testing.T) IDGenerator

NewIDGenerator is a simple way to create immutable id generator

func (IDGenerator) ID

func (g IDGenerator) ID() platform.ID

ID generates a new platform.ID from a mock function.

type ServerMock

type ServerMock struct {
	// contains filtered or unexported fields
}

func NewServerMock

func NewServerMock(prot string, host string, port uint16) *ServerMock

func (*ServerMock) Close

func (this *ServerMock) Close() error

func (*ServerMock) Start

func (this *ServerMock) Start() error

type TokenGenerator

type TokenGenerator struct {
	TokenFn func() (string, error)
}

TokenGenerator is mock implementation of platform.TokenGenerator.

func NewTokenGenerator

func NewTokenGenerator(s string, err error) TokenGenerator

NewTokenGenerator is a simple way to create immutable token generator.

func (TokenGenerator) Token

func (g TokenGenerator) Token() (string, error)

Token generates a new platform.Token from a mock function.

type ViewService

type ViewService struct {
	CreateViewF   func(context.Context, *platform.View) error
	FindViewByIDF func(context.Context, platform.ID) (*platform.View, error)
	FindViewsF    func(context.Context, platform.ViewFilter) ([]*platform.View, int, error)
	UpdateViewF   func(context.Context, platform.ID, platform.ViewUpdate) (*platform.View, error)
	DeleteViewF   func(context.Context, platform.ID) error
}

func (*ViewService) CreateView

func (s *ViewService) CreateView(ctx context.Context, b *platform.View) error

func (*ViewService) DeleteView

func (s *ViewService) DeleteView(ctx context.Context, id platform.ID) error

func (*ViewService) FindViewByID

func (s *ViewService) FindViewByID(ctx context.Context, id platform.ID) (*platform.View, error)

func (*ViewService) FindViews

func (s *ViewService) FindViews(ctx context.Context, filter platform.ViewFilter) ([]*platform.View, int, error)

func (*ViewService) UpdateView

func (s *ViewService) UpdateView(ctx context.Context, id platform.ID, upd platform.ViewUpdate) (*platform.View, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL