fixture

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fixture owns the shared YAML format for expression examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evaluate

func Evaluate(item Case) engine.Result

Evaluate executes a fixture using the production typed contract.

func Files

func Files(root string) (map[string][]Case, error)

Files loads all domain fixture files below root in stable order. Domain files may live beside their package or in internal/fixtures.

func InputJSON

func InputJSON(item Case) ([]byte, error)

InputJSON returns the fixture input in the evaluator's JSON form.

Types

type Case

type Case struct {
	Name       string       `yaml:"name"`
	Expression string       `yaml:"expression"`
	Input      any          `yaml:"input,omitempty"`
	At         string       `yaml:"at,omitempty"`
	Expect     *Expectation `yaml:"expect,omitempty"`
	Error      string       `yaml:"error,omitempty"`
	Benchmark  []string     `yaml:"benchmark,omitempty"`
}

Case is one expression fixture. Exactly one of Expect or Error must be set.

func Load

func Load(data []byte) ([]Case, error)

Load decodes and validates expression fixtures from YAML.

func LoadFile

func LoadFile(path string) ([]Case, error)

LoadFile reads and decodes one fixture file.

type Expectation

type Expectation struct {
	Type string `yaml:"type"`
	Out  any    `yaml:"out,omitempty"`
}

Expectation describes the stable typed result envelope.

Jump to

Keyboard shortcuts

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