mock

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package mock contains mock implementations of the query package interfaces for testing.

Index

Constants

This section is empty.

Variables

View Source
var NoMetadata <-chan flux.Metadata

Functions

func CreateMockFromSource added in v0.26.0

func CreateMockFromSource(spec plan.ProcedureSpec, id execute.DatasetID, ctx execute.Administration) (execute.Source, error)

CreateMockFromSource will register a mock "from" source. Use it like this in the init() of your test:

execute.RegisterSource(influxdb.FromKind, mock.CreateMockFromSource)

Types

type AscendingTimeProvider added in v0.21.0

type AscendingTimeProvider struct {
	Start int64
}

AscendingTimeProvider provides ascending timestamps every nanosecond starting from Start.

func (*AscendingTimeProvider) CurrentTime added in v0.21.0

func (atp *AscendingTimeProvider) CurrentTime() values.Time

type Compiler

type Compiler struct {
	CompileFn func(ctx context.Context) (flux.Program, error)
	Type      flux.CompilerType
}

func (Compiler) Compile

func (c Compiler) Compile(ctx context.Context) (flux.Program, error)

func (Compiler) CompilerType

func (c Compiler) CompilerType() flux.CompilerType

type Executor

type Executor struct {
	ExecuteFn func(ctx context.Context, p *plan.Spec, a *memory.Allocator) (map[string]flux.Result, <-chan flux.Metadata, error)
}

Executor is a mock implementation of an execute.Executor.

func NewExecutor

func NewExecutor() *Executor

NewExecutor returns a mock Executor where its methods will return zero values.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, p *plan.Spec, a *memory.Allocator) (map[string]flux.Result, <-chan flux.Metadata, error)

type Program added in v0.26.0

type Program struct {
	StartFn   func(ctx context.Context, alloc *memory.Allocator) (*Query, error)
	ExecuteFn func(ctx context.Context, q *Query, alloc *memory.Allocator)
}

Program is a mock program that can be returned by the mock compiler. It will construct a mock query that will then be passed to ExecuteFn.

func (*Program) Start added in v0.26.0

func (p *Program) Start(ctx context.Context, alloc *memory.Allocator) (flux.Query, error)

type Query added in v0.26.0

type Query struct {
	ResultsCh chan flux.Result
	CancelFn  func()
}

func (*Query) Cancel added in v0.26.0

func (q *Query) Cancel()

func (*Query) Done added in v0.26.0

func (q *Query) Done()

func (*Query) Err added in v0.26.0

func (q *Query) Err() error

func (*Query) Results added in v0.26.0

func (q *Query) Results() <-chan flux.Result

func (*Query) Statistics added in v0.26.0

func (q *Query) Statistics() flux.Statistics

type Source added in v0.26.0

type Source struct {
	AddTransformationFn func(transformation execute.Transformation)
	RunFn               func(ctx context.Context)
}

Source is a mock source that performs the given functions. By default it does nothing.

func (*Source) AddTransformation added in v0.26.0

func (s *Source) AddTransformation(t execute.Transformation)

func (*Source) Run added in v0.26.0

func (s *Source) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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