KeiSeiKit-1.0/_assembler/tests/golden.rs
Parfii-bot fdf1545631 refactor(tests): rename fixtures + regenerate snapshots for kei- prefix
- Rename 4 fixture manifests under _assembler/tests/fixtures/_manifests/
  ({code-implementer,cost-guardian,patent-compliance,researcher}.toml
  -> kei-<name>.toml) via git mv. Copy updated top-level manifests into
  fixtures so they stay byte-identical (fixtures mirror real manifests).
- Rename 4 snapshot files under _assembler/tests/snapshots/ to match
  the new insta snapshot keys.
- Update snapshot bodies to reflect the kei- prefix in:
  * frontmatter name field (name: kei-<n>)
  * GENERATED comment (_manifests/kei-<n>.toml)
  * handoff target lines
  * === HEADER === REPORT header (uppercased name in output_format)
- Update test code (golden.rs, roundtrip.rs, validator_negative.rs,
  determinism.rs) to use the new manifest filenames + snapshot keys.
  Rust function names (e.g. golden_researcher) untouched — they are
  internal identifiers, not manifest refs, and the word-boundary rule
  (no "_" preceding match) correctly skipped them.

Verify:
  cd _assembler && cargo test
  -> 17 tests passed (0 + 3 + 4 + 2 + 2 + 6 across 6 test files)
  -> Re-run produces no *.snap.new files (snapshots stable)

Regeneration path: because cargo-insta CLI is not installed on the
build host, the .snap.new files produced by the first (failing) test
run were accepted by renaming .snap.new -> .snap. Second cargo test
run passed cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 13:40:41 +08:00

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:
//!
//! - `kei-researcher` — minimal (only obligatory blocks)
//! - `kei-cost-guardian` — minimal + output_extra_fields
//! - `kei-patent-compliance` — minimal + references.extra
//! - `kei-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, "kei-researcher");
insta_settings().bind(|| insta::assert_snapshot!("kei-researcher", out));
}
#[test]
fn golden_cost_guardian() {
let (_tmp, root) = seed_tempdir();
let out = assemble_one(&root, "kei-cost-guardian");
insta_settings().bind(|| insta::assert_snapshot!("kei-cost-guardian", out));
}
#[test]
fn golden_patent_compliance() {
let (_tmp, root) = seed_tempdir();
let out = assemble_one(&root, "kei-patent-compliance");
insta_settings().bind(|| insta::assert_snapshot!("kei-patent-compliance", out));
}
#[test]
fn golden_code_implementer() {
let (_tmp, root) = seed_tempdir();
let out = assemble_one(&root, "kei-code-implementer");
insta_settings().bind(|| insta::assert_snapshot!("kei-code-implementer", out));
}