mock

package
v0.0.0-...-d500d3c Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNats

func NewNats() (nats.Publisher, nats.Subscriber)

NewNats returns a mocked version of publisher, subscriber

Types

type AuthorizationService

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

	// Methods for an platform.AuthorizationService
	FindAuthorizationByIDFn    func(context.Context, platform.ID) (*platform.Authorization, error)
	FindAuthorizationByTokenFn func(context.Context, string) (*platform.Authorization, error)
	FindAuthorizationsFn       func(context.Context, platform.AuthorizationFilter, ...platform.FindOptions) ([]*platform.Authorization, int, error)
	CreateAuthorizationFn      func(context.Context, *platform.Authorization) error
	DeleteAuthorizationFn      func(context.Context, platform.ID) error
	SetAuthorizationStatusFn   func(context.Context, platform.ID, platform.Status) error
}

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

func NewAuthorizationService

func NewAuthorizationService() *AuthorizationService

NewAuthorizationService returns a mock AuthorizationService where its methods will return zero values.

func (*AuthorizationService) CreateAuthorization

func (s *AuthorizationService) CreateAuthorization(ctx context.Context, authorization *platform.Authorization) error

CreateAuthorization creates a new authorization and sets b.ID with the new identifier.

func (*AuthorizationService) DeleteAuthorization

func (s *AuthorizationService) DeleteAuthorization(ctx context.Context, id platform.ID) error

DeleteAuthorization removes a authorization by ID.

func (*AuthorizationService) FindAuthorizationByID

func (s *AuthorizationService) FindAuthorizationByID(ctx context.Context, id platform.ID) (*platform.Authorization, error)

FindAuthorizationByID returns a single authorization by ID.

func (*AuthorizationService) FindAuthorizationByToken

func (s *AuthorizationService) FindAuthorizationByToken(ctx context.Context, t string) (*platform.Authorization, error)

func (*AuthorizationService) FindAuthorizations

FindAuthorizations returns a list of authorizations that match filter and the total count of matching authorizations.

func (*AuthorizationService) SetAuthorizationStatus

func (s *AuthorizationService) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error

type BasicAuthService

type BasicAuthService struct {
	SetPasswordFn           func(context.Context, string, string) error
	ComparePasswordFn       func(context.Context, string, string) error
	CompareAndSetPasswordFn func(context.Context, string, string, string) error
}

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

func NewBasicAuthService

func NewBasicAuthService(user, password string) *BasicAuthService

NewBasicAuthService returns a mock BasicAuthService where its methods will return zero values.

func (*BasicAuthService) CompareAndSetPassword

func (s *BasicAuthService) CompareAndSetPassword(ctx context.Context, name string, old string, new string) error

CompareAndSetPassword compares the provided password and sets it to the new password.

func (*BasicAuthService) ComparePassword

func (s *BasicAuthService) ComparePassword(ctx context.Context, name string, password string) error

ComparePassword password compares the provided password.

func (*BasicAuthService) SetPassword

func (s *BasicAuthService) SetPassword(ctx context.Context, name string, password string) error

SetPassword sets the users current password to be the provided password.

type BucketOperationLogService

type BucketOperationLogService struct {
	GetBucketOperationLogFn func(context.Context, platform.ID, platform.FindOptions) ([]*platform.OperationLogEntry, int, error)
}

BucketOperationLogService is a mock implementation of platform.BucketOperationLogService.

func NewBucketOperationLogService

func NewBucketOperationLogService() *BucketOperationLogService

NewBucketOperationLogService returns a mock of BucketOperationLogService.

func (*BucketOperationLogService) GetBucketOperationLog

GetBucketOperationLog retrieves the operation log for the bucket with the provided id.

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 (*DBRPMappingService) FindBy

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

func (*DBRPMappingService) FindMany

type DashboardOperationLogService

type DashboardOperationLogService struct {
	GetDashboardOperationLogFn func(context.Context, platform.ID, platform.FindOptions) ([]*platform.OperationLogEntry, int, error)
}

DashboardOperationLogService is a mock implementation of platform.DashboardOperationLogService.

func NewDashboardOperationLogService

func NewDashboardOperationLogService() *DashboardOperationLogService

NewDashboardOperationLogService returns a mock of DashboardOperationLogService.

func (*DashboardOperationLogService) GetDashboardOperationLog

GetDashboardOperationLog retrieves the operation log for the dashboard with the provided id.

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.FindOptions) ([]*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
	GetDashboardCellViewF    func(ctx context.Context, dashboardID platform.ID, cellID platform.ID) (*platform.View, error)
	UpdateDashboardCellViewF func(ctx context.Context, dashboardID platform.ID, cellID platform.ID, upd platform.ViewUpdate) (*platform.View, 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 (*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 (*DashboardService) GetDashboardCellView

func (s *DashboardService) GetDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID) (*platform.View, 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 (*DashboardService) UpdateDashboardCell

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

func (*DashboardService) UpdateDashboardCellView

func (s *DashboardService) UpdateDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID, upd platform.ViewUpdate) (*platform.View, error)

type GroupCursor

type GroupCursor struct {
	NextFunc             func() bool
	CursorFunc           func() cursors.Cursor
	TagsFunc             func() models.Tags
	KeysFunc             func() [][]byte
	PartitionKeyValsFunc func() [][]byte
	CloseFunc            func()
	ErrFunc              func() error
	StatsFunc            func() cursors.CursorStats
}

func NewGroupCursor

func NewGroupCursor() *GroupCursor

func (*GroupCursor) Close

func (c *GroupCursor) Close()

func (*GroupCursor) Cursor

func (c *GroupCursor) Cursor() cursors.Cursor

func (*GroupCursor) Err

func (c *GroupCursor) Err() error

func (*GroupCursor) Keys

func (c *GroupCursor) Keys() [][]byte

func (*GroupCursor) Next

func (c *GroupCursor) Next() bool

func (*GroupCursor) PartitionKeyVals

func (c *GroupCursor) PartitionKeyVals() [][]byte

func (*GroupCursor) Stats

func (c *GroupCursor) Stats() cursors.CursorStats

func (*GroupCursor) Tags

func (c *GroupCursor) Tags() models.Tags

type GroupResultSet

type GroupResultSet struct {
	NextFunc  func() reads.GroupCursor
	CloseFunc func()
	ErrFunc   func() error
}

func NewGroupResultSet

func NewGroupResultSet() *GroupResultSet

func (*GroupResultSet) Close

func (rs *GroupResultSet) Close()

func (*GroupResultSet) Err

func (rs *GroupResultSet) Err() error

func (*GroupResultSet) Next

func (rs *GroupResultSet) Next() reads.GroupCursor

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 IntegerArrayCursor

type IntegerArrayCursor struct {
	CloseFunc func()
	Errfunc   func() error
	StatsFunc func() cursors.CursorStats
	NextFunc  func() *cursors.IntegerArray
}

func NewIntegerArrayCursor

func NewIntegerArrayCursor() *IntegerArrayCursor

func (*IntegerArrayCursor) Close

func (c *IntegerArrayCursor) Close()

func (*IntegerArrayCursor) Err

func (c *IntegerArrayCursor) Err() error

func (*IntegerArrayCursor) Next

func (*IntegerArrayCursor) Stats

type LabelService

type LabelService struct {
	FindLabelsFn  func(context.Context, platform.LabelFilter) ([]*platform.Label, error)
	CreateLabelFn func(context.Context, *platform.Label) error
	UpdateLabelFn func(context.Context, *platform.Label, platform.LabelUpdate) (*platform.Label, error)
	DeleteLabelFn func(context.Context, platform.Label) error
}

LabelService is a mock implementation of platform.LabelService

func NewLabelService

func NewLabelService() *LabelService

NewLabelService returns a mock of LabelService where its methods will return zero values.

func (*LabelService) CreateLabel

func (s *LabelService) CreateLabel(ctx context.Context, l *platform.Label) error

CreateLabel creates a new Label.

func (*LabelService) DeleteLabel

func (s *LabelService) DeleteLabel(ctx context.Context, l platform.Label) error

DeleteLabel removes a Label.

func (*LabelService) FindLabels

func (s *LabelService) FindLabels(ctx context.Context, filter platform.LabelFilter, opt ...platform.FindOptions) ([]*platform.Label, error)

FindLabels finds mappings that match a given filter.

func (*LabelService) UpdateLabel

func (s *LabelService) UpdateLabel(ctx context.Context, l *platform.Label, upd platform.LabelUpdate) (*platform.Label, error)

UpdateLabel updates a label.

type LookupService

type LookupService struct {
	NameFn func(ctx context.Context, resource platform.Resource, id platform.ID) (string, error)
}

LookupService provides field lookup for the resource and ID.

func (*LookupService) Name

func (s *LookupService) Name(ctx context.Context, resource platform.Resource, id platform.ID) (string, error)

Name returns the name for the resource and ID.

type MacroService

type MacroService struct {
	FindMacrosF    func(context.Context) ([]*platform.Macro, error)
	FindMacroByIDF func(context.Context, platform.ID) (*platform.Macro, error)
	CreateMacroF   func(context.Context, *platform.Macro) error
	UpdateMacroF   func(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error)
	ReplaceMacroF  func(context.Context, *platform.Macro) error
	DeleteMacroF   func(context.Context, platform.ID) error
}

func (*MacroService) CreateMacro

func (s *MacroService) CreateMacro(ctx context.Context, macro *platform.Macro) error

func (*MacroService) DeleteMacro

func (s *MacroService) DeleteMacro(ctx context.Context, id platform.ID) error

func (*MacroService) FindMacroByID

func (s *MacroService) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error)

func (*MacroService) FindMacros

func (s *MacroService) FindMacros(ctx context.Context) ([]*platform.Macro, error)

func (*MacroService) ReplaceMacro

func (s *MacroService) ReplaceMacro(ctx context.Context, macro *platform.Macro) error

func (*MacroService) UpdateMacro

func (s *MacroService) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error)

type NatsPublisher

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

NatsPublisher is a mocked nats publisher.

func (*NatsPublisher) Publish

func (p *NatsPublisher) Publish(subject string, r io.Reader) error

Publish add subject and msg to server.

type NatsServer

type NatsServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NatsServer is the mocked nats server based buffered channel.

type NatsSubscriber

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

NatsSubscriber is mocked nats subscriber.

func (*NatsSubscriber) Subscribe

func (s *NatsSubscriber) Subscribe(subject, group string, handler nats.Handler) error

Subscribe implements nats.Subscriber inteferface.

type OnboardingService

OnboardingService is a mock implementation of platform.OnboardingService.

func NewOnboardingService

func NewOnboardingService() *OnboardingService

NewOnboardingService returns a mock of OnboardingService where its methods will return zero values.

func (*OnboardingService) Generate

Generate OnboardingResults.

func (*OnboardingService) IsOnboarding

func (s *OnboardingService) IsOnboarding(ctx context.Context) (bool, error)

IsOnboarding determine if onboarding request is allowed.

type OrganizationOperationLogService

type OrganizationOperationLogService struct {
	GetOrganizationOperationLogFn func(context.Context, platform.ID, platform.FindOptions) ([]*platform.OperationLogEntry, int, error)
}

OrganizationOperationLogService is a mock implementation of platform.OrganizationOperationLogService.

func NewOrganizationOperationLogService

func NewOrganizationOperationLogService() *OrganizationOperationLogService

NewOrganizationOperationLogService returns a mock of OrganizationOperationLogService.

func (*OrganizationOperationLogService) GetOrganizationOperationLog

func (s *OrganizationOperationLogService) GetOrganizationOperationLog(ctx context.Context, id platform.ID, opts platform.FindOptions) ([]*platform.OperationLogEntry, int, error)

GetOrganizationOperationLog retrieves the operation log for the org with the provided id.

type OrganizationService

type OrganizationService struct {
	FindOrganizationByIDF func(ctx context.Context, id platform.ID) (*platform.Organization, error)
	FindOrganizationF     func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error)
	FindOrganizationsF    func(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error)
	CreateOrganizationF   func(ctx context.Context, b *platform.Organization) error
	UpdateOrganizationF   func(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error)
	DeleteOrganizationF   func(ctx context.Context, id platform.ID) error
}

OrganizationService is a mock organization server.

func (*OrganizationService) CreateOrganization

func (s *OrganizationService) CreateOrganization(ctx context.Context, b *platform.Organization) error

CreateOrganization calls CreateOrganizationF.

func (*OrganizationService) DeleteOrganization

func (s *OrganizationService) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization calls DeleteOrganizationF.

func (*OrganizationService) FindOrganization

FindOrganization calls FindOrganizationF.

func (*OrganizationService) FindOrganizationByID

func (s *OrganizationService) FindOrganizationByID(ctx context.Context, id platform.ID) (*platform.Organization, error)

FindOrganizationByID calls FindOrganizationByIDF.

func (*OrganizationService) FindOrganizations

FindOrganizations calls FindOrganizationsF.

func (*OrganizationService) UpdateOrganization

UpdateOrganization calls UpdateOrganizationF.

type PagingFilter

type PagingFilter struct {
	Name string
	Type []string
}

func (PagingFilter) QueryParams

func (f PagingFilter) QueryParams() map[string][]string

type PointsWriter

type PointsWriter struct {
	Points []models.Point
	Err    error
	// contains filtered or unexported fields
}

PointsWriter is a mock structure for writing points.

func (*PointsWriter) ForceError

func (p *PointsWriter) ForceError(err error)

ForceError is for error testing, if WritePoints is called after ForceError, it will return that error.

func (*PointsWriter) Next

func (p *PointsWriter) Next() models.Point

Next returns the next (oldest) batch of values.

func (*PointsWriter) WritePoints

func (p *PointsWriter) WritePoints(points []models.Point) error

WritePoints writes points to the PointsWriter that will be exposed in the Values.

type ProtoService

type ProtoService struct {
	FindProtosFn                func(context.Context) ([]*platform.Proto, error)
	CreateDashboardsFromProtoFn func(context.Context, platform.ID, platform.ID) ([]*platform.Dashboard, error)
}

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

func (*ProtoService) CreateDashboardsFromProto

func (s *ProtoService) CreateDashboardsFromProto(ctx context.Context, protoID, orgID platform.ID) ([]*platform.Dashboard, error)

CreateDashboardsFromProto creates a new set of dashboards for a proto

func (*ProtoService) FindProtos

func (s *ProtoService) FindProtos(ctx context.Context) ([]*platform.Proto, error)

FindProtos returns a list of protos.

type ProxyQueryService

type ProxyQueryService struct {
	QueryFn func(context.Context, io.Writer, *query.ProxyRequest) (int64, error)
}

ProxyQueryService is a mock implementation of a query.ProxyQueryService.

func NewProxyQueryService

func NewProxyQueryService() *ProxyQueryService

NewProxyQueryService returns a mock of ProxyQueryService where its methods will return zero values.

func (*ProxyQueryService) Query

Query performs the requested query and encodes the results into w.

type ResponseStream

type ResponseStream struct {
	SendFunc       func(*datatypes.ReadResponse) error
	SetTrailerFunc func(metadata.MD)
}

func NewResponseStream

func NewResponseStream() *ResponseStream

func (*ResponseStream) Send

func (*ResponseStream) SetTrailer

func (s *ResponseStream) SetTrailer(m metadata.MD)

type ResultSet

type ResultSet struct {
	NextFunc   func() bool
	CursorFunc func() cursors.Cursor
	TagsFunc   func() models.Tags
	CloseFunc  func()
	ErrFunc    func() error
	StatsFunc  func() cursors.CursorStats
}

func NewResultSet

func NewResultSet() *ResultSet

func (*ResultSet) Close

func (rs *ResultSet) Close()

func (*ResultSet) Cursor

func (rs *ResultSet) Cursor() cursors.Cursor

func (*ResultSet) Err

func (rs *ResultSet) Err() error

func (*ResultSet) Next

func (rs *ResultSet) Next() bool

func (*ResultSet) Stats

func (rs *ResultSet) Stats() cursors.CursorStats

func (*ResultSet) Tags

func (rs *ResultSet) Tags() models.Tags

type RetentionService

type RetentionService struct {
	WithLoggerFn           func(l *zap.Logger)
	OpenFn                 func() error
	CloseFn                func() error
	PrometheusCollectorsFn func() []prometheus.Collector
}

func NewRetentionService

func NewRetentionService() *RetentionService

func (*RetentionService) Close

func (s *RetentionService) Close() error

func (*RetentionService) Open

func (s *RetentionService) Open() error

func (*RetentionService) PrometheusCollectors

func (s *RetentionService) PrometheusCollectors() []prometheus.Collector

func (*RetentionService) WithLogger

func (s *RetentionService) WithLogger(log *zap.Logger)

type 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)
}

ScraperTargetStoreService is a mock implementation of a platform.ScraperTargetStoreService.

func (*ScraperTargetStoreService) AddTarget

AddTarget adds a scraper target.

func (*ScraperTargetStoreService) GetTargetByID

GetTargetByID retrieves a scraper target by id.

func (*ScraperTargetStoreService) ListTargets

ListTargets lists all the scraper targets.

func (*ScraperTargetStoreService) RemoveTarget

func (s *ScraperTargetStoreService) RemoveTarget(ctx context.Context, id platform.ID) error

RemoveTarget deletes a scraper target.

func (*ScraperTargetStoreService) UpdateTarget

UpdateTarget updates a scraper target.

type SecretService

type SecretService struct {
	LoadSecretFn    func(ctx context.Context, orgID platform.ID, k string) (string, error)
	GetSecretKeysFn func(ctx context.Context, orgID platform.ID) ([]string, error)
	PutSecretFn     func(ctx context.Context, orgID platform.ID, k string, v string) error
	PutSecretsFn    func(ctx context.Context, orgID platform.ID, m map[string]string) error
	PatchSecretsFn  func(ctx context.Context, orgID platform.ID, m map[string]string) error
	DeleteSecretFn  func(ctx context.Context, orgID platform.ID, ks ...string) error
}

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

func NewSecretService

func NewSecretService() *SecretService

NewSecretService returns a mock SecretService where its methods will return zero values.

func (*SecretService) DeleteSecret

func (s *SecretService) DeleteSecret(ctx context.Context, orgID platform.ID, ks ...string) error

DeleteSecret removes a single secret from the secret store.

func (*SecretService) GetSecretKeys

func (s *SecretService) GetSecretKeys(ctx context.Context, orgID platform.ID) ([]string, error)

GetSecretKeys retrieves all secret keys that are stored for the organization orgID.

func (*SecretService) LoadSecret

func (s *SecretService) LoadSecret(ctx context.Context, orgID platform.ID, k string) (string, error)

LoadSecret retrieves the secret value v found at key k for organization orgID.

func (*SecretService) PatchSecrets

func (s *SecretService) PatchSecrets(ctx context.Context, orgID platform.ID, m map[string]string) error

PatchSecrets patches all provided secrets and updates any previous values.

func (*SecretService) PutSecret

func (s *SecretService) PutSecret(ctx context.Context, orgID platform.ID, k string, v string) error

PutSecret stores the secret pair (k,v) for the organization orgID.

func (*SecretService) PutSecrets

func (s *SecretService) PutSecrets(ctx context.Context, orgID platform.ID, m map[string]string) error

PutSecrets puts all provided secrets and overwrites any previous values.

type SessionService

type SessionService struct {
	FindSessionFn   func(context.Context, string) (*platform.Session, error)
	ExpireSessionFn func(context.Context, string) error
	CreateSessionFn func(context.Context, string) (*platform.Session, error)
}

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

func NewSessionService

func NewSessionService() *SessionService

NewSessionService returns a mock SessionService where its methods will return zero values.

func (*SessionService) CreateSession

func (s *SessionService) CreateSession(ctx context.Context, user string) (*platform.Session, error)

CreateSession creates a sesion for a user with the users maximal privileges.

func (*SessionService) ExpireSession

func (s *SessionService) ExpireSession(ctx context.Context, key string) error

ExpireSession exires the session provided at key.

func (*SessionService) FindSession

func (s *SessionService) FindSession(ctx context.Context, key string) (*platform.Session, error)

FindSession returns the session found at the provided key.

type SourceService

type SourceService struct {
	DefaultSourceFn  func(context.Context) (*platform.Source, error)
	FindSourceByIDFn func(context.Context, platform.ID) (*platform.Source, error)
	FindSourcesFn    func(context.Context, platform.FindOptions) ([]*platform.Source, int, error)
	CreateSourceFn   func(context.Context, *platform.Source) error
	UpdateSourceFn   func(context.Context, platform.ID, platform.SourceUpdate) (*platform.Source, error)
	DeleteSourceFn   func(context.Context, platform.ID) error
}

SourceService is a mock implementation of platform.SourceService.

func NewSourceService

func NewSourceService() *SourceService

NewSourceService returns a mock of SourceService where its methods will return zero values.

func (*SourceService) CreateSource

func (s *SourceService) CreateSource(ctx context.Context, source *platform.Source) error

CreateSource sets the sources ID and stores it.

func (*SourceService) DefaultSource

func (s *SourceService) DefaultSource(ctx context.Context) (*platform.Source, error)

DefaultSource retrieves the default source.

func (*SourceService) DeleteSource

func (s *SourceService) DeleteSource(ctx context.Context, id platform.ID) error

DeleteSource removes the source.

func (*SourceService) FindSourceByID

func (s *SourceService) FindSourceByID(ctx context.Context, id platform.ID) (*platform.Source, error)

FindSourceByID retrieves a source by its ID.

func (*SourceService) FindSources

func (s *SourceService) FindSources(ctx context.Context, opts platform.FindOptions) ([]*platform.Source, int, error)

FindSources returns a list of all sources.

func (*SourceService) UpdateSource

func (s *SourceService) UpdateSource(ctx context.Context, id platform.ID, upd platform.SourceUpdate) (*platform.Source, error)

UpdateSource updates the source.

type TaskService

type TaskService struct {
	FindTaskByIDFn func(context.Context, platform.ID) (*platform.Task, error)
	FindTasksFn    func(context.Context, platform.TaskFilter) ([]*platform.Task, int, error)
	CreateTaskFn   func(context.Context, *platform.Task) error
	UpdateTaskFn   func(context.Context, platform.ID, platform.TaskUpdate) (*platform.Task, error)
	DeleteTaskFn   func(context.Context, platform.ID) error
	FindLogsFn     func(context.Context, platform.LogFilter) ([]*platform.Log, int, error)
	FindRunsFn     func(context.Context, platform.RunFilter) ([]*platform.Run, int, error)
	FindRunByIDFn  func(context.Context, platform.ID, platform.ID) (*platform.Run, error)
	CancelRunFn    func(context.Context, platform.ID, platform.ID) error
	RetryRunFn     func(context.Context, platform.ID, platform.ID) (*platform.Run, error)
	ForceRunFn     func(context.Context, platform.ID, int64) (*platform.Run, error)
}

func (*TaskService) CancelRun

func (s *TaskService) CancelRun(ctx context.Context, taskID, runID platform.ID) error

func (*TaskService) CreateTask

func (s *TaskService) CreateTask(ctx context.Context, t *platform.Task) error

func (*TaskService) DeleteTask

func (s *TaskService) DeleteTask(ctx context.Context, id platform.ID) error

func (*TaskService) FindLogs

func (s *TaskService) FindLogs(ctx context.Context, filter platform.LogFilter) ([]*platform.Log, int, error)

func (*TaskService) FindRunByID

func (s *TaskService) FindRunByID(ctx context.Context, taskID, runID platform.ID) (*platform.Run, error)

func (*TaskService) FindRuns

func (s *TaskService) FindRuns(ctx context.Context, filter platform.RunFilter) ([]*platform.Run, int, error)

func (*TaskService) FindTaskByID

func (s *TaskService) FindTaskByID(ctx context.Context, id platform.ID) (*platform.Task, error)

func (*TaskService) FindTasks

func (s *TaskService) FindTasks(ctx context.Context, filter platform.TaskFilter) ([]*platform.Task, int, error)

func (*TaskService) ForceRun

func (s *TaskService) ForceRun(ctx context.Context, taskID platform.ID, scheduledFor int64) (*platform.Run, error)

func (*TaskService) RetryRun

func (s *TaskService) RetryRun(ctx context.Context, taskID, runID platform.ID) (*platform.Run, error)

func (*TaskService) UpdateTask

func (s *TaskService) UpdateTask(ctx context.Context, id platform.ID, upd platform.TaskUpdate) (*platform.Task, error)

type TelegrafConfigStore

type TelegrafConfigStore struct {
	FindUserResourceMappingsF  func(ctx context.Context, filter platform.UserResourceMappingFilter, opt ...platform.FindOptions) ([]*platform.UserResourceMapping, int, error)
	CreateUserResourceMappingF func(ctx context.Context, m *platform.UserResourceMapping) error
	DeleteUserResourceMappingF func(ctx context.Context, resourceID platform.ID, userID platform.ID) error
	FindTelegrafConfigByIDF    func(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error)
	FindTelegrafConfigF        func(ctx context.Context, filter platform.TelegrafConfigFilter) (*platform.TelegrafConfig, error)
	FindTelegrafConfigsF       func(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error)
	CreateTelegrafConfigF      func(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error
	UpdateTelegrafConfigF      func(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error)
	DeleteTelegrafConfigF      func(ctx context.Context, id platform.ID) error
}

TelegrafConfigStore represents a service for managing telegraf config data.

func (*TelegrafConfigStore) CreateTelegrafConfig

func (s *TelegrafConfigStore) CreateTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error

CreateTelegrafConfig creates a new telegraf config and sets b.ID with the new identifier.

func (*TelegrafConfigStore) CreateUserResourceMapping

func (s *TelegrafConfigStore) CreateUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error

CreateUserResourceMapping creates a user resource mapping

func (*TelegrafConfigStore) DeleteTelegrafConfig

func (s *TelegrafConfigStore) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error

DeleteTelegrafConfig removes a telegraf config by ID.

func (*TelegrafConfigStore) DeleteUserResourceMapping

func (s *TelegrafConfigStore) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

DeleteUserResourceMapping deletes a user resource mapping

func (*TelegrafConfigStore) FindTelegrafConfig

FindTelegrafConfig returns the first telegraf config that matches filter.

func (*TelegrafConfigStore) FindTelegrafConfigByID

func (s *TelegrafConfigStore) FindTelegrafConfigByID(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error)

FindTelegrafConfigByID returns a single telegraf config by ID.

func (*TelegrafConfigStore) FindTelegrafConfigs

FindTelegrafConfigs returns a list of telegraf configs that match filter and the total count of matching telegraf configs. Additional options provide pagination & sorting.

func (*TelegrafConfigStore) FindUserResourceMappings

FindUserResourceMappings returns a list of UserResourceMappings that match filter and the total count of matching mappings.

func (*TelegrafConfigStore) UpdateTelegrafConfig

func (s *TelegrafConfigStore) UpdateTelegrafConfig(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error)

UpdateTelegrafConfig updates a single telegraf config. Returns the new telegraf config after update.

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 UserOperationLogService

type UserOperationLogService struct {
	GetUserOperationLogFn func(context.Context, platform.ID, platform.FindOptions) ([]*platform.OperationLogEntry, int, error)
}

UserOperationLogService is a mock implementation of platform.UserOperationLogService.

func NewUserOperationLogService

func NewUserOperationLogService() *UserOperationLogService

NewUserOperationLogService returns a mock of UserOperationLogService.

func (*UserOperationLogService) GetUserOperationLog

GetUserOperationLog retrieves the operation log for the user with the provided id.

type UserResourceMappingService

type UserResourceMappingService struct {
	FindMappingsFn  func(context.Context, platform.UserResourceMappingFilter) ([]*platform.UserResourceMapping, int, error)
	CreateMappingFn func(context.Context, *platform.UserResourceMapping) error
	DeleteMappingFn func(context.Context, platform.ID, platform.ID) error
}

UserResourceMappingService is a mock implementation of platform.UserResourceMappingService

func NewUserResourceMappingService

func NewUserResourceMappingService() *UserResourceMappingService

NewUserResourceMappingService returns a mock of UserResourceMappingService where its methods will return zero values.

func (*UserResourceMappingService) CreateUserResourceMapping

func (s *UserResourceMappingService) CreateUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error

CreateUserResourceMapping creates a new UserResourceMapping.

func (*UserResourceMappingService) DeleteUserResourceMapping

func (s *UserResourceMappingService) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

DeleteUserResourceMapping removes a UserResourceMapping.

func (*UserResourceMappingService) FindUserResourceMappings

FindUserResourceMappings finds mappings that match a given filter.

type UserService

type UserService struct {
	// Methods for a platform.UserService
	FindUserByIDFn func(context.Context, platform.ID) (*platform.User, error)
	FindUsersFn    func(context.Context, platform.UserFilter, ...platform.FindOptions) ([]*platform.User, int, error)
	CreateUserFn   func(context.Context, *platform.User) error
	DeleteUserFn   func(context.Context, platform.ID) error
	FindUserFn     func(context.Context, platform.UserFilter) (*platform.User, error)
	UpdateUserFn   func(context.Context, platform.ID, platform.UserUpdate) (*platform.User, error)
}

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

func NewUserService

func NewUserService() *UserService

NewUserService returns a mock of NewUserService where its methods will return zero values.

func (*UserService) CreateUser

func (s *UserService) CreateUser(ctx context.Context, User *platform.User) error

CreateUser creates a new User and sets b.ID with the new identifier.

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser removes a User by ID.

func (*UserService) FindUser

func (s *UserService) FindUser(ctx context.Context, filter platform.UserFilter) (*platform.User, error)

FindUser finds the first user that matches a filter

func (*UserService) FindUserByID

func (s *UserService) FindUserByID(ctx context.Context, id platform.ID) (*platform.User, error)

FindUserByID returns a single User by ID.

func (*UserService) FindUsers

func (s *UserService) FindUsers(ctx context.Context, filter platform.UserFilter, opts ...platform.FindOptions) ([]*platform.User, int, error)

FindUsers returns a list of Users that match filter and the total count of matching Users.

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(ctx context.Context, id platform.ID, upd platform.UserUpdate) (*platform.User, error)

UpdateUser updates a user

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)

type WriteService

type WriteService struct {
	WriteF func(context.Context, platform.ID, platform.ID, io.Reader) error
}

WriteService writes data read from the reader.

func (*WriteService) Write

func (s *WriteService) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error

Write calls the mocked WriteF function with arguments.

Jump to

Keyboard shortcuts

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