mock

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mock contains mock implementations of different task interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	ExecutedChan chan scheduler.ID
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor() *Executor

func (*Executor) Cancel

func (e *Executor) Cancel(context.Context, influxdb.ID) error

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, id scheduler.ID, scheduledAt time.Time, runAt time.Time) error

func (*Executor) FailNextCallToExecute

func (e *Executor) FailNextCallToExecute(err error)

FailNextCallToExecute causes the next call to e.Execute to unconditionally return err.

func (*Executor) ManualRun

func (e *Executor) ManualRun(ctx context.Context, id influxdb.ID, runID influxdb.ID) (executor.Promise, error)

func (*Executor) Wait

func (e *Executor) Wait()

type TaskControlService

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

TaskControlService is a mock implementation of TaskControlService (used by NewScheduler).

func NewTaskControlService

func NewTaskControlService() *TaskControlService

func (*TaskControlService) AddRunLog

func (d *TaskControlService) AddRunLog(ctx context.Context, taskID, runID influxdb.ID, when time.Time, log string) error

AddRunLog adds a log line to the run.

func (*TaskControlService) CreateRun

func (t *TaskControlService) CreateRun(_ context.Context, taskID influxdb.ID, scheduledFor time.Time, runAt time.Time) (*influxdb.Run, error)

func (*TaskControlService) CreatedFor

func (d *TaskControlService) CreatedFor(taskID influxdb.ID) []*influxdb.Run

func (*TaskControlService) CurrentlyRunning

func (t *TaskControlService) CurrentlyRunning(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)

func (*TaskControlService) FinishRun

func (d *TaskControlService) FinishRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)

func (*TaskControlService) FinishedRun

func (d *TaskControlService) FinishedRun(runID influxdb.ID) *influxdb.Run

func (*TaskControlService) FinishedRuns

func (d *TaskControlService) FinishedRuns() []*influxdb.Run

func (*TaskControlService) ManualRuns

func (t *TaskControlService) ManualRuns(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)

func (*TaskControlService) PollForNumberCreated

func (d *TaskControlService) PollForNumberCreated(taskID influxdb.ID, count int) ([]*influxdb.Run, error)

PollForNumberCreated blocks for a small amount of time waiting for exactly the given count of created and unfinished runs for the given task ID. If the expected number isn't found in time, it returns an error.

Because the scheduler and executor do a lot of state changes asynchronously, this is useful in test.

func (*TaskControlService) SetManualRuns

func (d *TaskControlService) SetManualRuns(runs []*influxdb.Run)

func (*TaskControlService) SetTask

func (d *TaskControlService) SetTask(task *influxdb.Task)

SetTask sets the task. SetTask must be called before CreateNextRun, for a given task ID.

func (*TaskControlService) StartManualRun

func (t *TaskControlService) StartManualRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)

func (*TaskControlService) TotalRunsCreatedForTask

func (d *TaskControlService) TotalRunsCreatedForTask(taskID influxdb.ID) int

TotalRunsCreatedForTask returns the number of runs created for taskID.

func (*TaskControlService) UpdateRunState

func (d *TaskControlService) UpdateRunState(ctx context.Context, taskID, runID influxdb.ID, when time.Time, state influxdb.RunStatus) error

UpdateRunState sets the run state at the respective time.

Jump to

Keyboard shortcuts

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