testutils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertWorkflowSpec

func AssertWorkflowSpec(t *testing.T, expectedSpec, testWorkflowSpec sdk.WorkflowSpec)

Types

type Mock

type Mock[I, O any] struct {
	// contains filtered or unexported fields
}

func MockCapability

func MockCapability[I, O any](id string, fn func(I) (O, error)) *Mock[I, O]

func (Mock) Execute

func (Mock) GetStep

func (m Mock) GetStep(ref string) StepResults[I, O]

func (Mock) ID

func (m Mock) ID() string

func (Mock) Info

func (m Mock) Info(ctx context.Context) (capabilities.CapabilityInfo, error)

func (Mock) RegisterToWorkflow

func (m Mock) RegisterToWorkflow(ctx context.Context, request capabilities.RegisterToWorkflowRequest) error

func (Mock) UnregisterFromWorkflow

func (m Mock) UnregisterFromWorkflow(ctx context.Context, request capabilities.UnregisterFromWorkflowRequest) error

type NoopRuntime

type NoopRuntime struct{}

func (*NoopRuntime) Emitter added in v0.1.1

func (nr *NoopRuntime) Emitter() sdk.MessageEmitter

func (*NoopRuntime) Fetch

func (*NoopRuntime) Logger

func (nr *NoopRuntime) Logger() logger.Logger

type Runner

type Runner struct {
	RawConfig []byte
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(ctx context.Context) *Runner

func (*Runner) Config

func (r *Runner) Config() []byte

func (*Runner) Err

func (r *Runner) Err() error

func (*Runner) GetRegisteredMock

func (r *Runner) GetRegisteredMock(name string, step string) capabilities.ActionCapability

func (*Runner) MockCapability

func (r *Runner) MockCapability(name string, step *string, capability capabilities.ExecutableCapability)

MockCapability registers a new capability mock with the runner if the step is not nil, the capability will be registered for that step If a step is explicitly mocked, that will take priority over a mock of the entire capability. This is best used with generated code to ensure correctness Note that mocks of custom compute will not be used in place of the user's code

func (*Runner) MockTrigger

func (r *Runner) MockTrigger(trigger capabilities.TriggerCapability)

func (*Runner) Run

func (r *Runner) Run(factory *sdk.WorkflowSpecFactory)

type StepResults

type StepResults[I, O any] struct {
	WasRun bool
	Input  I
	Output O
	Error  error
}

type TargetMock

type TargetMock[I any] struct {
	// contains filtered or unexported fields
}

func MockTarget

func MockTarget[I any](id string, fn func(I) error) *TargetMock[I]

func (TargetMock) Execute

func (m TargetMock) Execute(ctx context.Context, request capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error)

func (*TargetMock[I]) GetAllWrites

func (t *TargetMock[I]) GetAllWrites() TargetResults[I]

func (TargetMock) GetStep

func (m TargetMock) GetStep(ref string) StepResults[I, O]

func (TargetMock) ID

func (m TargetMock) ID() string

func (TargetMock) Info

func (m TargetMock) Info(ctx context.Context) (capabilities.CapabilityInfo, error)

func (TargetMock) RegisterToWorkflow

func (m TargetMock) RegisterToWorkflow(ctx context.Context, request capabilities.RegisterToWorkflowRequest) error

func (TargetMock) UnregisterFromWorkflow

func (m TargetMock) UnregisterFromWorkflow(ctx context.Context, request capabilities.UnregisterFromWorkflowRequest) error

type TargetResults

type TargetResults[I any] struct {
	NumRuns int
	Inputs  []I
	Errors  []error
}

type TriggerMock

type TriggerMock[O any] struct {
	// contains filtered or unexported fields
}

func MockTrigger

func MockTrigger[O any](id string, fn func() (O, error)) *TriggerMock[O]

func (TriggerMock) Execute

func (m TriggerMock) Execute(ctx context.Context, request capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error)

func (*TriggerMock[O]) GetStep

func (t *TriggerMock[O]) GetStep() TriggerResults[O]

func (TriggerMock) ID

func (m TriggerMock) ID() string

func (TriggerMock) Info

func (m TriggerMock) Info(ctx context.Context) (capabilities.CapabilityInfo, error)

func (TriggerMock) RegisterToWorkflow

func (m TriggerMock) RegisterToWorkflow(ctx context.Context, request capabilities.RegisterToWorkflowRequest) error

func (*TriggerMock[O]) RegisterTrigger

func (TriggerMock) UnregisterFromWorkflow

func (m TriggerMock) UnregisterFromWorkflow(ctx context.Context, request capabilities.UnregisterFromWorkflowRequest) error

func (*TriggerMock[O]) UnregisterTrigger

func (t *TriggerMock[O]) UnregisterTrigger(ctx context.Context, request capabilities.TriggerRegistrationRequest) error

type TriggerResults

type TriggerResults[O any] struct {
	Output O
	Error  error
}

Jump to

Keyboard shortcuts

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