tasktest

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestController

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

	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) RealmID

func (c *TestController) RealmID() string

RealmID 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.

Jump to

Keyboard shortcuts

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