Back to godoc.org

Package tasktest

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Index

type TestController

type TestController struct {
	OverrideJobID string // return value of JobID() if not ""
	OverrideInvID int64  // return value of InvocationID() if not 0

	Req task.Request // return value of Request

	TaskMessage proto.Message // return value of Task
	TaskState   task.State    // return value of State(), mutated in place
	Client      *http.Client  // return value by GetClient()
	Log         []string      // individual log lines passed to DebugLog()

	SaveCallback         func() error                         // mock for Save()
	PrepareTopicCallback func(string) (string, string, error) // mock for PrepareTopic()

	Timers   []TimerSpec
	Triggers []*internal.Trigger
}

TestController implements task.Controller and can be used in unit tests.

func (*TestController) AddTimer

func (c *TestController) AddTimer(ctx context.Context, delay time.Duration, name string, payload []byte)

AddTimer is part of Controller interface.

func (*TestController) DebugLog

func (c *TestController) DebugLog(format string, args ...interface{})

DebugLog is part of Controller interface.

func (*TestController) EmitTrigger

func (c *TestController) EmitTrigger(ctx context.Context, trigger *internal.Trigger)

func (*TestController) GetClient

func (c *TestController) GetClient(ctx context.Context, opts ...auth.RPCOption) (*http.Client, error)

GetClient is part of Controller interface.

func (*TestController) InvocationID

func (c *TestController) InvocationID() int64

InvocationID is part of Controller interface.

func (*TestController) JobID

func (c *TestController) JobID() string

JobID is part of Controller interface.

func (*TestController) PrepareTopic

func (c *TestController) PrepareTopic(ctx context.Context, publisher string) (topic string, token string, err error)

PrepareTopic is part of Controller interface.

func (*TestController) Request

func (c *TestController) Request() task.Request

Request is part of Controller interface.

func (*TestController) Save

func (c *TestController) Save(ctx context.Context) error

Save is part of Controller interface.

func (*TestController) State

func (c *TestController) State() *task.State

State is part of Controller interface.

func (*TestController) Task

func (c *TestController) Task() proto.Message

Task is part of Controller interface.

type TimerSpec

type TimerSpec struct {
	Delay   time.Duration
	Name    string
	Payload []byte
}

TimerSpec corresponds to single AddTimer call.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier