KeiSeiKit-1.0/_primitives/_rust/kei-registry/tests/diff_smoke.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

40 lines
1.6 KiB
Rust

//! `diff_blocks` walks all four facets and reports differences.
use kei_registry::{diff_blocks, open_db, register, BlockType};
use tempfile::tempdir;
#[test]
fn identical_blocks_have_no_differs() {
let tmp = tempdir().unwrap();
let conn = open_db(tmp.path().join("r.sqlite")).unwrap();
let a = register(&conn, BlockType::Atom, "x", "/p1", b"body", "md").unwrap();
let b = register(&conn, BlockType::Atom, "x", "/p1", b"body", "md").unwrap();
let d = diff_blocks(&a, &b);
assert!(d.differs.is_empty(), "identical re-register → no differs");
assert_eq!(d.identical.len(), 4, "all 4 facets identical");
}
#[test]
fn different_paths_diff_scope_sha() {
let tmp = tempdir().unwrap();
let conn = open_db(tmp.path().join("r.sqlite")).unwrap();
let a = register(&conn, BlockType::Atom, "x", "/p1", b"body", "md").unwrap();
let b = register(&conn, BlockType::Atom, "x", "/p2", b"body", "md").unwrap();
let d = diff_blocks(&a, &b);
assert!(
d.differs.iter().any(|s| s == "scope_sha"),
"scope_sha must be flagged as differing for different paths"
);
assert!(d.identical.iter().any(|s| s == "body_sha"));
assert!(d.identical.iter().any(|s| s == "block_type"));
}
#[test]
fn different_block_types_diff_block_type_facet() {
let tmp = tempdir().unwrap();
let conn = open_db(tmp.path().join("r.sqlite")).unwrap();
let a = register(&conn, BlockType::Atom, "x", "/p1", b"body", "md").unwrap();
let b = register(&conn, BlockType::Rule, "y", "/p2", b"body2", "md").unwrap();
let d = diff_blocks(&a, &b);
assert!(d.differs.iter().any(|s| s == "block_type"));
}