mock

package
v0.0.0-...-98ba599 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mock contains a minimal, mocked implementation of a fnenv for test purposes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

Func is the type for mocked functions used in the mock.Runtime

type Resolver

type Resolver struct {
	FnNameIDs map[string]string
}

Resolver is a mocked implementation of a RuntimeResolver.

Use FnNameIDs to setup a mapping to mock resolving function references to IDs.

func NewResolver

func NewResolver() *Resolver

func (*Resolver) Resolve

func (mf *Resolver) Resolve(ref types.FnRef) (string, error)

type Runtime

type Runtime struct {
	Functions       map[string]Func
	AsyncResults    map[string]*types.TaskInvocation
	ManualExecution bool
}

Runtime mocks the implementation of the various runtime.

Mock functions can be added to Functions, and should have the mocked function id as the key. For AsyncRuntime the results are stored and retrieved from the AsyncResults. The result is added automatically/instantly using the function, but can be avoided by enabling ManualExecution.

Note it does not mock the resolver, which is mocked by the mock.Resolver

func NewRuntime

func NewRuntime() *Runtime

func (*Runtime) Cancel

func (mk *Runtime) Cancel(fnInvocationID string) error

func (*Runtime) Invoke

func (*Runtime) InvokeAsync

func (mk *Runtime) InvokeAsync(spec *types.TaskInvocationSpec, opts ...fnenv.InvokeOption) (string, error)

func (*Runtime) MockComplete

func (mk *Runtime) MockComplete(fnInvocationID string) error

func (*Runtime) Notify

func (mk *Runtime) Notify(taskID string, fn types.FnRef, expectedAt time.Time) error

func (*Runtime) Status

func (mk *Runtime) Status(fnInvocationID string) (*types.TaskInvocationStatus, error)

Jump to

Keyboard shortcuts

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