Sheet document v2, report v3 / v2 / identity, migration map, sheet snapshot, branding, PDF labels and archive envelope ported from the Zod schemas with their exact semantics: strict objects where Zod is strict, optional fields absent (never null), nullable fields required, integers as JavaScript numbers, UTF-16 caps, hand-checked patterns, url crate for .url(), lone surrogate escapes read as U+FFFD (L1, owner confirmation pending). Fields in Zod schema order (PDF labels in the engine dictionary order): the curated and legacy sheets, the demo report and the three frozen archive envelopes print byte for byte as their Zod / attachment form. ts-rs types regenerated; plan rev 2 after three plan challenges.
26 lines
965 B
Rust
26 lines
965 B
Rust
//! Shared helpers of the core integration tests: repository files and the Zod oracles.
|
|
#![allow(
|
|
dead_code,
|
|
clippy::disallowed_methods,
|
|
clippy::unwrap_used,
|
|
clippy::expect_used
|
|
)]
|
|
|
|
use serde_json::Value;
|
|
|
|
/// A repository file, by path from the repository root.
|
|
pub fn repo_file(relative: &str) -> String {
|
|
let path = format!("{}/../../{relative}", env!("CARGO_MANIFEST_DIR"));
|
|
std::fs::read_to_string(&path).unwrap_or_else(|error| panic!("{path}: {error}"))
|
|
}
|
|
|
|
/// A Zod oracle (`crates/core/tests/oracles/<name>`): its source file and the Zod output in
|
|
/// the JavaScript pretty form.
|
|
pub fn zod_oracle(name: &str) -> (String, String) {
|
|
let oracle: Value =
|
|
serde_json::from_str(&repo_file(&format!("crates/core/tests/oracles/{name}"))).unwrap();
|
|
let source = oracle["source"].as_str().unwrap().to_owned();
|
|
let output = faunosteo_core::json::to_js_pretty(&oracle["output"]).unwrap();
|
|
(repo_file(&source), output)
|
|
}
|