Add tests/golden.rs with insta-backed snapshot assertions for: - researcher (minimal — 3 obligatory blocks only) - cost-guardian (minimal + output_extra_fields) - patent-compliance (minimal + references.extra) - code-implementer (obligatory + 4 implementer-specific blocks) Coverage: all four frontmatter fields (name/description/tools/model), role body, block concatenation order, domain_in / forbidden_domain / handoffs / output format (including extra fields) / references (both optional memory_project + project_claudemd and references.extra). The snapshots in tests/snapshots/*.snap are the signed contract — any change to assembler.rs output must be reviewed via `cargo insta review` and committed alongside the code change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.9 KiB
Rust
56 lines
1.9 KiB
Rust
//! Golden-file snapshot tests for the assembler.
|
|
//!
|
|
//! Contract under test: `same manifest + blocks → byte-identical .md`
|
|
//! (assembler.rs:2). This file locks the generated output for 4
|
|
//! representative manifests:
|
|
//!
|
|
//! - `researcher` — minimal (only obligatory blocks)
|
|
//! - `cost-guardian` — minimal + output_extra_fields
|
|
//! - `patent-compliance` — minimal + references.extra
|
|
//! - `code-implementer` — obligatory + 4 implementer blocks
|
|
//!
|
|
//! First run generates `tests/snapshots/*.snap.new`; approve with
|
|
//! `cargo insta review`. Subsequent runs assert byte-equality against
|
|
//! the approved snapshot. Any drift in assembler output will fail loudly.
|
|
|
|
mod common;
|
|
|
|
use common::{assemble_one, seed_tempdir};
|
|
|
|
/// Point insta at `tests/snapshots/` (not the default
|
|
/// `tests/snapshots/` inside each test binary) and use our own stable
|
|
/// snapshot naming scheme.
|
|
fn insta_settings() -> insta::Settings {
|
|
let mut s = insta::Settings::clone_current();
|
|
s.set_snapshot_path("snapshots");
|
|
s.set_prepend_module_to_snapshot(false);
|
|
s
|
|
}
|
|
|
|
#[test]
|
|
fn golden_researcher() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let out = assemble_one(&root, "researcher");
|
|
insta_settings().bind(|| insta::assert_snapshot!("researcher", out));
|
|
}
|
|
|
|
#[test]
|
|
fn golden_cost_guardian() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let out = assemble_one(&root, "cost-guardian");
|
|
insta_settings().bind(|| insta::assert_snapshot!("cost-guardian", out));
|
|
}
|
|
|
|
#[test]
|
|
fn golden_patent_compliance() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let out = assemble_one(&root, "patent-compliance");
|
|
insta_settings().bind(|| insta::assert_snapshot!("patent-compliance", out));
|
|
}
|
|
|
|
#[test]
|
|
fn golden_code_implementer() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let out = assemble_one(&root, "code-implementer");
|
|
insta_settings().bind(|| insta::assert_snapshot!("code-implementer", out));
|
|
}
|