stage

package
v0.0.0-...-a6b0214 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnimplemented = fmt.Errorf("unimplemented")

Functions

func Benchmark

func Benchmark(b *testing.B, fn StageFunc, cases []TestCase)

Test runs the provided test cases against the StageFunc.

func Bool

func Bool(name string, value bool, usage string) *bool

func Debug

func Debug() bool

func Int

func Int(name string, value int, usage string) *int

Int defines an integer flag on the command line.

func Open

func Open(name string) io.Reader

func Print

func Print(a ...any) (n int, err error)

func Printf

func Printf(format string, a ...any) (n int, err error)

func Println

func Println(a ...any) (n int, err error)

func Reader

func Reader(input any) (io.Reader, error)

Reader converts some classic input type as io.Reader.

func RunCLI

func RunCLI(input any, fns ...StageFunc)

RunCLI is a CLI helper to run stages.

func SetFS

func SetFS(f fs.FS)

func String

func String(name string, value string, usage string) *string

Int defines a string flag on the command line.

func Test

func Test(t *testing.T, fn StageFunc, cases []TestCase)

Test runs the provided test cases against the StageFunc.

func Verbose

func Verbose() bool

Types

type StageFunc

type StageFunc func(input io.Reader) (any, error)

StageFunc is the stage function signature.

type TestCase

type TestCase struct {
	// Name of the test
	Name string
	// Input can be []byte, string, or io.Reader
	Input any
	// Result can be of any type
	Result any
	// Error
	Err error
	// Flags
	Flags map[string]string
}

TestCase represents the input and expected result of a test. Tests will individually run under the provided name. Input supports different types that will be converted to io.Reader. Result can be of any type, but it has to match the function result to succeed. Err is usually nil, but if we expect one, it can be given here.

Jump to

Keyboard shortcuts

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