mock

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 12 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, platform.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 platform.ID, runID platform.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 platform.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 platform.ID, scheduledFor time.Time, runAt time.Time) (*taskmodel.Run, error)

func (*TaskControlService) CreatedFor

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

func (*TaskControlService) CurrentlyRunning

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

func (*TaskControlService) FinishRun

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

func (*TaskControlService) FinishedRun

func (d *TaskControlService) FinishedRun(runID platform.ID) *taskmodel.Run

func (*TaskControlService) FinishedRuns

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

func (*TaskControlService) ManualRuns

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

func (*TaskControlService) PollForNumberCreated

func (d *TaskControlService) PollForNumberCreated(taskID platform.ID, count int) ([]*taskmodel.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 []*taskmodel.Run)

func (*TaskControlService) SetTask

func (d *TaskControlService) SetTask(task *taskmodel.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 platform.ID) (*taskmodel.Run, error)

func (*TaskControlService) TotalRunsCreatedForTask

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

TotalRunsCreatedForTask returns the number of runs created for taskID.

func (*TaskControlService) UpdateRunState

func (d *TaskControlService) UpdateRunState(ctx context.Context, taskID, runID platform.ID, when time.Time, state taskmodel.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