Version: v0.99.3 Latest Latest

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 11 Imported by: 0



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



This section is empty.


View Source
var NoMetadata <-chan metadata.Metadata


func CreateMockFromSource

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)


type Administration

type Administration struct {
	// contains filtered or unexported fields

Administration is a mock implementation of the execute.Administration interface. This may be used for tests that require implementation of this interface.

func AdministrationWithContext

func AdministrationWithContext(ctx context.Context) *Administration

func (*Administration) Allocator

func (a *Administration) Allocator() *memory.Allocator

func (*Administration) Context

func (a *Administration) Context() context.Context

func (*Administration) Parents

func (a *Administration) Parents() []execute.DatasetID

func (*Administration) ResolveTime

func (a *Administration) ResolveTime(qt flux.Time) execute.Time

func (*Administration) StreamContext

func (a *Administration) StreamContext() execute.StreamContext

type AscendingTimeProvider

type AscendingTimeProvider struct {
	Start int64

AscendingTimeProvider provides ascending timestamps every nanosecond starting from Start.

func (*AscendingTimeProvider) CurrentTime

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, runtime flux.Runtime) (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 metadata.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 metadata.Metadata, error)

type Program

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

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

type Query

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

	Canceled chan struct{}
	// contains filtered or unexported fields

Query provides a customizable query that implements flux.Query. Results, as well as errors, statistics, and the cancel function can be set.

func (*Query) Cancel

func (q *Query) Cancel()

func (*Query) Done

func (q *Query) Done()

func (*Query) Err

func (q *Query) Err() error

func (*Query) ProduceResults

func (q *Query) ProduceResults(resultProvider func(results chan<- flux.Result, canceled <-chan struct{}))

ProduceResults lets the user provide a function to produce results on the channel returned by `Results`. `resultProvider` should check if `canceled` has been closed before sending results. E.g.: ```

 func (results chan<- flux.Result, canceled <-chan struct{}) {
	 for _, r := range resultsSlice {
		 select {
		 case <-canceled:
			 results <- r

``` `resultProvider` is run in a separate goroutine and Results() is closed after function completion. ProduceResults can be called only once per Query.

func (*Query) ProfilerResults

func (q *Query) ProfilerResults() (flux.ResultIterator, error)

func (*Query) Results

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

func (*Query) SetErr

func (q *Query) SetErr(err error)

SetErr sets the error for this query and `Cancel`s it

func (*Query) SetStatistics

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

SetStatistics sets stats for this query. Stats will be available after `Done` is called.

func (*Query) Statistics

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

type SecretService

type SecretService map[string]string

func (SecretService) LoadSecret

func (s SecretService) LoadSecret(ctx context.Context, k string) (string, error)

type Source

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

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

func (*Source) Run

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