KeiSeiKit-1.0/_primitives/_rust/kei-machine-probe/tests/profile_json_roundtrip.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

47 lines
1.5 KiB
Rust

//! Machine struct JSON roundtrip — bytes equal after re-serialise.
use kei_machine_probe::{
AppleVariant, ArchInfo, CpuFamily, GpuInfo, Machine, MemoryInfo, OsFamily, OsInfo,
ToolingInfo,
};
fn sample() -> Machine {
Machine {
os: OsInfo { family: OsFamily::Macos, version: "14.5".into(), build: "23F79".into() },
arch: ArchInfo {
family: CpuFamily::AppleSilicon(AppleVariant::M2Pro),
brand: "Apple M2 Pro".into(),
model_id: "Mac14,7".into(),
cores: 10,
},
memory: MemoryInfo {
total_bytes: 17_179_869_184,
available_bytes: 5_000_000_000,
pressure_pct: 50,
},
gpu: GpuInfo::AppleIntegrated { cores: 19, name: "Apple M2 Pro".into() },
tooling: ToolingInfo {
ollama: Some("0.3.12".into()),
homebrew: Some("4.3.20".into()),
llama_cpp: None,
},
source_commands: vec!["sysctl -n hw.model".into(), "vm_stat".into()],
}
}
#[test]
fn roundtrip_preserves_struct() {
let m = sample();
let json = serde_json::to_string_pretty(&m).expect("serialize");
let m2: Machine = serde_json::from_str(&json).expect("deserialize");
assert_eq!(m, m2);
}
#[test]
fn roundtrip_bytes_are_stable() {
let m = sample();
let j1 = serde_json::to_string_pretty(&m).expect("serialize 1");
let m2: Machine = serde_json::from_str(&j1).expect("deserialize");
let j2 = serde_json::to_string_pretty(&m2).expect("serialize 2");
assert_eq!(j1, j2);
}