Documentation
¶
Overview ¶
Package testutil provides shared testing utilities for the pasture test suite.
LoadFixtures reads a named YAML fixture from the caller's testdata/ directory and unmarshals it into the supplied target value. Tests that rely on this function will fail immediately (via require) if the fixture file is missing or malformed, keeping test failures actionable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFixtures ¶
func LoadFixtures(t *testing.T, name FixtureName, target any)
LoadFixtures reads testdata/<name>.yaml relative to the current working directory (the package under test) and unmarshals the contents into target.
It calls t.Helper() so that failure lines point to the caller, and uses require (not assert) so that the test stops immediately on infrastructure failures rather than proceeding with a zero-value target.
Parameters:
- t: the active *testing.T (must not be nil).
- name: one of the FixtureName constants — determines the file path.
- target: a non-nil pointer that yaml.Unmarshal will populate.
Failure modes (both call t.FailNow via require):
- The fixture file does not exist at testdata/<name>.yaml.
- The YAML content cannot be unmarshalled into target.
Types ¶
type FixtureName ¶
type FixtureName string
FixtureName is a typed string that identifies a YAML fixture file stored under the calling package's testdata/ directory. Using a named type instead of a plain string prevents accidental string literals at call sites.
const ( // ContentBlock is used by S2–S3 tests (message/content-block scenarios). ContentBlock FixtureName = "content_block" // CLISmoke is used by S4–S5 tests (CLI smoke / handler scenarios). CLISmoke FixtureName = "cli_smoke" // RunAgentSession is used by S5–S6 tests (Temporal workflow scenarios). RunAgentSession FixtureName = "run_agent_session" // ConfigLoading is used by S3 tests (config loading scenarios). ConfigLoading FixtureName = "config_loading" // CodegenMarkers is used by S3 codegen tests (marker parsing scenarios). CodegenMarkers FixtureName = "markers" // CodegenContext is used by S2 codegen tests (context injection scenarios). CodegenContext FixtureName = "context" // CodegenAgents is used by S6 codegen tests (agent definition generation scenarios). CodegenAgents FixtureName = "agents" // CodegenSkills is used by S4 codegen tests (SKILL.md generation scenarios). CodegenSkills FixtureName = "skills" // CodegenSchema is used by S5 codegen tests (schema.xml generation scenarios). CodegenSchema FixtureName = "schema" )