stage

package
v0.0.0-...-7d7b408 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 14 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 Debug

func Debug() bool

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 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
}

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