functiontest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 18 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.

func InputsMatchSynthesizerRefs added in v0.1.23

func InputsMatchSynthesizerRefs(t require.TestingT, inputObject any, synthesizerPath string, mode KeyMatchMode)

InputsMatchSynthesizerRefs is ensures your synthsizers references stay in sync with the eno_keys to the struct you give function.SynthFunc The level of sync can be defined by the KeyMatchMode parameter

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.

func ValidateResourceMeta added in v0.1.31

func ValidateResourceMeta[T function.Inputs]() Assertion[T]

ValidateResourceMeta is an Assertion that proves the outputs are valid resources from Eno's perspective e.g. contain only valid metadata like eno.azure.io/* annotations.

type KeyMatchMode added in v0.1.23

type KeyMatchMode int
const (
	KeyMatchStrict  KeyMatchMode = iota // all eno_keys must have a corresponding ref
	KeyMatchRelaxed                     // eno_keys can be a subset of refs
)

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