testkit

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testkit provides flow-runner-specific test helpers.

This package is intentionally separate from github.com/nexssp/testkit: the generic testkit has no dependency on flow, and this package needs one. Keeping them apart means a project that never runs flows does not pull flow into its test binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

Result captures the outcome of one flow run inside a test.

Stdout and Stderr hold the exact bytes the runner would have written to the terminal, so a test can assert on the live trace, the metrics table, or the banner without spawning a subprocess.

func RunDSL

func RunDSL(
	t testing.TB,
	dsl string,
	payload map[string]any,
	libs ...flow.Library,
) Result

RunDSL executes a flow body directly, without reading a .flow file.

The DSL is treated as if it were the content of a .flow file: it may contain @config, @pipeline, and @assert directives, but not @include or @require (those need a real file on disk).

payload is passed as the initial state. libs is the library set the DSL may call; pass at least flow.StandardLibrary().

func (Result) ExpectFailure

func (r Result) ExpectFailure(t testing.TB) Result

ExpectFailure fails the test when the flow exited with code 0.

func (Result) ExpectSuccess

func (r Result) ExpectSuccess(t testing.TB) Result

ExpectSuccess fails the test when the flow did not exit cleanly.

func (Result) StdoutContains

func (r Result) StdoutContains(t testing.TB, substr string) Result

StdoutContains fails the test when the captured stdout does not contain substr. Useful for asserting on live trace lines.

Jump to

Keyboard shortcuts

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