acceptance

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package acceptance is packtrail's black-box acceptance suite: every test drives a real engine, real workers and a real embedded nats-server through the public API only, with fault injection (engine kill and restart, NATS restart, duplicate and reordered completions). Each scenario pins a guaranteed behaviour.

Index

Constants

View Source
const DefaultTimeout = 60 * time.Second

DefaultTimeout bounds every acceptance test.

Variables

This section is empty.

Functions

func Echo

func Echo(_ context.Context, j *worker.Job) (*worker.Result, error)

Echo is a handler returning {"node": <node>, "input": <input>}.

func JSON

func JSON(t *testing.T, raw json.RawMessage) any

JSON decodes raw into a generic value.

Types

type Env

type Env struct {
	T      *testing.T
	S      *natstest.Server
	Ctx    context.Context //nolint:containedctx // test-scoped context.
	Client *packtrail.Client
	// Engine is the first engine started.
	Engine *packtrail.Engine
	// contains filtered or unexported fields
}

Env is one test deployment.

func NewEnv

func NewEnv(t *testing.T, flows []string, opts ...packtrail.Option) *Env

NewEnv starts NATS, provisions the namespace with the given flows and starts one engine.

func (*Env) Completed

func (e *Env) Completed(id string) *packtrail.State

Completed waits and asserts a completed execution.

func (*Env) Eventually

func (e *Env) Eventually(cond func() bool, msg func() string)

Eventually polls cond until it holds or the test context ends.

func (*Env) KillEngines

func (e *Env) KillEngines()

KillEngines stops every running engine (gracefully: in-flight commands drain) and waits for them.

func (*Env) NC

func (e *Env) NC() *nats.Conn

NC returns a fresh connection.

func (*Env) Register

func (e *Env) Register(yaml string) string

Register registers a flow at runtime.

func (*Env) RestartEngine

func (e *Env) RestartEngine()

RestartEngine replaces every engine with a fresh one.

func (*Env) Start

func (e *Env) Start(flowName string, input any, opts ...packtrail.StartOption) string

Start starts flowName and returns the execution id.

func (*Env) StartEngine

func (e *Env) StartEngine(extra ...packtrail.Option) *packtrail.Engine

StartEngine starts another engine process (own connection).

func (*Env) Wait

func (e *Env) Wait(id string) *packtrail.State

Wait waits for a terminal state.

func (*Env) WaitStatus

func (e *Env) WaitStatus(id string, want packtrail.Status) *packtrail.State

WaitStatus waits until the execution has status want.

func (*Env) Worker

func (e *Env) Worker(kind string, h worker.Handler, opts ...worker.Option)

Worker starts a worker for kind.

Jump to

Keyboard shortcuts

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