//! 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/`): 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) }