Documentation ¶
Overview ¶
Package mock contains mock implementations of different task interfaces.
Index ¶
- type Executor
- func (e *Executor) Cancel(context.Context, platform.ID) error
- func (e *Executor) Execute(ctx context.Context, id scheduler.ID, scheduledAt time.Time, runAt time.Time) error
- func (e *Executor) FailNextCallToExecute(err error)
- func (e *Executor) ManualRun(ctx context.Context, id platform.ID, runID platform.ID) (executor.Promise, error)
- func (e *Executor) Wait()
- type TaskControlService
- func (d *TaskControlService) AddRunLog(ctx context.Context, taskID, runID platform.ID, when time.Time, log string) error
- func (t *TaskControlService) CreateRun(_ context.Context, taskID platform.ID, scheduledFor time.Time, runAt time.Time) (*taskmodel.Run, error)
- func (d *TaskControlService) CreatedFor(taskID platform.ID) []*taskmodel.Run
- func (t *TaskControlService) CurrentlyRunning(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)
- func (d *TaskControlService) FinishRun(_ context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)
- func (d *TaskControlService) FinishedRun(runID platform.ID) *taskmodel.Run
- func (d *TaskControlService) FinishedRuns() []*taskmodel.Run
- func (t *TaskControlService) ManualRuns(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)
- func (d *TaskControlService) PollForNumberCreated(taskID platform.ID, count int) ([]*taskmodel.Run, error)
- func (d *TaskControlService) SetManualRuns(runs []*taskmodel.Run)
- func (d *TaskControlService) SetTask(task *taskmodel.Task)
- func (t *TaskControlService) StartManualRun(_ context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)
- func (d *TaskControlService) TotalRunsCreatedForTask(taskID platform.ID) int
- func (d *TaskControlService) UpdateRunState(ctx context.Context, taskID, runID platform.ID, when time.Time, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
func NewExecutor ¶
func NewExecutor() *Executor
func (*Executor) FailNextCallToExecute ¶
FailNextCallToExecute causes the next call to e.Execute to unconditionally return err.
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) CreatedFor ¶
func (d *TaskControlService) CreatedFor(taskID platform.ID) []*taskmodel.Run
func (*TaskControlService) CurrentlyRunning ¶
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 (*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 (*TaskControlService) TotalRunsCreatedForTask ¶
func (d *TaskControlService) TotalRunsCreatedForTask(taskID platform.ID) int
TotalRunsCreatedForTask returns the number of runs created for taskID.