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§
- Fixture
Error - Errors from fixture I/O.
Functions§
- load
- Load any
FromSExprtype from a file path. - load_
data_ source - Load an
IacDataSourcefrom a fixture file. - load_
provider - Load an
IacProviderfrom a fixture file. - load_
provider_ str - Parse an
IacProviderfrom a fixture string. - load_
resource - Load an
IacResourcefrom a fixture file. - load_
resource_ str - Parse an
IacResourcefrom a fixture string. - load_
str - Load any
FromSExprtype from a string (forinclude_str!or tests). - save
- Save any
ToSExprtype to a file path in canonical emission. - save_
data_ source - Save an
IacDataSourceto a fixture file. - save_
provider - Save an
IacProviderto a fixture file. - save_
resource - Save an
IacResourceto a fixture file.