Skip to main content

Module fixtures

Module fixtures 

Source
Expand description

Sexpr-based test fixtures for backends and cross-repo tests.

The backend crates historically hand-constructed IacResource and IacAttribute test fixtures as Rust literals. When the IR grew new fields (json_encoded, optional, update_only) those literals went stale, silently in some repos and loudly in others. Fixtures stored as canonical sexpr text avoid that drift: the IR owns the sexpr shape, every consumer loads through the same canonical path, and adding a field only requires editing the fixtures once.

§Pattern

Write a fixture:

use iac_forge::testing::fixtures;
use iac_forge::testing::test_resource;

let resource = test_resource("widget");
fixtures::save_resource(&resource, "tests/fixtures/widget.sexpr").unwrap();

Load it back in tests:

use iac_forge::testing::fixtures;

let resource = fixtures::load_resource("tests/fixtures/widget.sexpr").unwrap();
assert_eq!(resource.name, "widget");

String-based loaders (_str variants) are equivalent but skip disk I/O — useful for tests that embed the fixture via include_str!.

Enums§

FixtureError
Errors from fixture I/O.

Functions§

load
Load any FromSExpr type from a file path.
load_data_source
Load an IacDataSource from a fixture file.
load_provider
Load an IacProvider from a fixture file.
load_provider_str
Parse an IacProvider from a fixture string.
load_resource
Load an IacResource from a fixture file.
load_resource_str
Parse an IacResource from a fixture string.
load_str
Load any FromSExpr type from a string (for include_str! or tests).
save
Save any ToSExpr type to a file path in canonical emission.
save_data_source
Save an IacDataSource to a fixture file.
save_provider
Save an IacProvider to a fixture file.
save_resource
Save an IacResource to a fixture file.