KeiSeiKit-1.0/_primitives/_rust/kei-registry/tests/scanner_primitive.rs
Parfii-bot a4e667de10 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

45 lines
1.5 KiB
Rust

//! Primitive scanner walks `<kit>/_primitives/_rust/*/Cargo.toml` and
//! emits one Block per crate with `[package].name`.
use kei_registry::scanners::primitive::PrimitiveScanner;
use kei_registry::scanners::Scanner;
use kei_registry::BlockType;
use std::path::PathBuf;
fn fixture_kit_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("fixtures")
.join("fake-kit")
}
#[test]
fn primitive_scanner_finds_one_crate() {
let found = PrimitiveScanner.scan(&fixture_kit_root()).unwrap();
assert_eq!(found.len(), 1, "fake-kit has one crate");
let f = &found[0];
assert_eq!(f.block_type, BlockType::Primitive);
assert_eq!(f.name, "foo", "name comes from [package].name");
assert!(f.path.ends_with("Cargo.toml"), "path is the Cargo.toml file");
}
#[test]
fn primitive_scanner_body_is_cargo_toml() {
let found = PrimitiveScanner.scan(&fixture_kit_root()).unwrap();
let body_text = std::str::from_utf8(&found[0].body).unwrap();
assert!(body_text.contains("name = \"foo\""), "body is the actual TOML");
}
#[test]
fn primitive_scanner_extracts_caps_from_deps() {
let found = PrimitiveScanner.scan(&fixture_kit_root()).unwrap();
let caps = &found[0].caps;
assert!(caps.contains("regex"), "regex dep maps to caps token");
}
#[test]
fn primitive_scanner_missing_root_returns_empty() {
let bad = PathBuf::from("/this/path/does/not/exist");
let found = PrimitiveScanner.scan(&bad).unwrap();
assert!(found.is_empty());
}