fixture

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package fixture produces fixture pairs (left/right) with known planted differences, in every supported format, plus a manifest.json of the ground truth. It is simultaneously the test oracle, the benchmark dataset generator, and the cross-format test bed (see bench/gen for the CLI).

Values are pure functions of (seed, key, column), so any subset of rows is reproducible. The right side is written in a different physical row order to prove keyed diffing is order-independent.

Index

Constants

View Source
const (
	TolerableDelta = 0.001
	ToleranceAbs   = 0.01
)

TolerableDelta is how far a planted tolerable row's float columns move, and ToleranceAbs is the --tolerance that must absorb it while still catching every genuinely changed row (whose float columns move by 1.5). Both sit on the generator's 3-decimal float grid, so they survive a CSV round trip exactly.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Rows       int64
	Cols       int // including the id key column
	Seed       uint64
	PctChanged float64
	PctAdded   float64
	PctRemoved float64
	// PctTolerable plants rows whose only differences are float nudges of
	// TolerableDelta: inside ToleranceAbs, outside exact comparison. They
	// are the oracle for --tolerance. Variants with no float column (stringy)
	// cannot plant them and emit unchanged rows instead.
	PctTolerable float64
	Out          string   // output directory
	Formats      []string // "parquet", "csv"
	Variant      string   // standard | wide | stringy
}

Config parameterizes one generated fixture pair.

type Manifest

type Manifest struct {
	Seed          uint64           `json:"seed"`
	Variant       string           `json:"variant"`
	Columns       int              `json:"columns"`
	RowsLeft      int64            `json:"rows_left"`
	RowsRight     int64            `json:"rows_right"`
	Added         int64            `json:"added"`
	Removed       int64            `json:"removed"`
	Changed       int64            `json:"changed"`
	ColumnChanges map[string]int64 `json:"column_changes"`
	// Tolerable counts rows whose only differences are inside ToleranceAbs;
	// a diff run with that tolerance must report exactly this many as
	// "within tolerance" and none of them as changed.
	Tolerable     int64   `json:"tolerable"`
	ToleranceAbs  float64 `json:"tolerance_abs,omitempty"`
	TolerableKeys []int64 `json:"tolerable_keys,omitempty"`
	KeysCapped    bool    `json:"keys_capped"`
	AddedKeys     []int64 `json:"added_keys,omitempty"`
	RemovedKeys   []int64 `json:"removed_keys,omitempty"`
	ChangedKeys   []int64 `json:"changed_keys,omitempty"`
}

Manifest records the exact planted ground truth of a fixture pair.

func Generate

func Generate(cfg Config) (*Manifest, error)

Generate writes the fixture pair described by cfg plus manifest.json, and returns the manifest.

Jump to

Keyboard shortcuts

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