contracttest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(body []byte, blankTopLevelExecTime bool) ([]byte, error)

Normalize decodes a JSON response body and blanks the parts that are expected to vary from run to run, so the remaining shape can be diffed against a golden file.

It always blanks:

  • any object key named "request_id" (recursively, any nesting level)
  • any string value that looks like an RFC3339 timestamp (recursively, any nesting level, regardless of key name)

When blankTopLevelExecTime is true, it additionally blanks the top-level "execution_time_ms" key (used only for the /sql/execute golden, whose value is wall-clock and therefore nondeterministic). It never blanks execution_time_ms nested inside other structures (e.g. /sql/queries record objects), because those values are deterministic aggregations and regressions in them must fail the golden comparison.

The result is re-encoded with object keys sorted (Go's encoding/json sorts map[string]interface{} keys on Marshal) and 2-space indentation, for a stable, readable diff.

func WriteFixtureLogs

func WriteFixtureLogs(dir string) error

WriteFixtureLogs writes two MySQL slow-log files into dir with timestamps relative to now, so /sql/queries' default now-15d window always includes them. Deterministic except for the sliding timestamps.

Types

type Fixture

type Fixture struct {
	Path  string           // for tests that open their own StorageManager
	Store *storage.Storage // read-only handle, closed via t.Cleanup
}

Fixture is a seeded, read-only DuckDB plus its file path.

func BuildFixtureDB

func BuildFixtureDB(t testing.TB) Fixture

BuildFixtureDB generates the fixture logs, parses them into a temp DuckDB, and returns a read-only handle. Deterministic (bar sliding timestamps).

Directories

Path Synopsis
cmd
genfixture command

Jump to

Keyboard shortcuts

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