functiontest

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evaluate

func Evaluate[T function.Inputs](t *testing.T, synth function.SynthFunc[T], scenarios ...Scenario[T])

Evaluate runs the synthesizer function with the provided scenarios and asserts on the outputs.

Types

type Assertion

type Assertion[T function.Inputs] func(t *testing.T, s *Scenario[T], outputs []client.Object)

func AssertionChain

func AssertionChain[T function.Inputs](asserts ...Assertion[T]) Assertion[T]

AssertionChain is a helper function to create an assertion that runs multiple assertions in sequence.

func LoadSnapshots

func LoadSnapshots[T function.Inputs](t *testing.T, dir string) Assertion[T]

LoadSnapshots returns an assertion that will compare the outputs of a synthesizer function with the expected outputs stored in snapshot files.

Scenarios that do not have a corresponding snapshot file will be ignored. To generate snapshots, set the ENO_GEN_SNAPSHOTS environment variable to a non-empty value.

So, to bootstrap snapshots for a given fixture/scenario: create an empty snapshot file that matches the name of the scenario (or fixture if using LoadScenarios), and run the tests with ENO_GEN_SNAPSHOTS=true.

type Scenario

type Scenario[T function.Inputs] struct {
	Name      string
	Inputs    T
	Assertion Assertion[T]
}

Scenario represents a test case for a synthesizer function.

func LoadScenarios

func LoadScenarios[T any](t *testing.T, dir string, assertion Assertion[T]) []Scenario[T]

LoadScenarios recursively loads yaml and json input fixtures from the specified directory.

Jump to

Keyboard shortcuts

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