//! Report contracts against the Zod oracles. #![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)] mod common; use faunosteo_core::domain::js::parse_json; use faunosteo_core::domain::report::v2::ReportV2; use faunosteo_core::domain::report::{Report, ReportMigrationMap}; use faunosteo_core::json::to_js_pretty; #[test] fn the_demo_report_prints_as_zod_outputs_it() { let (source, expected) = common::zod_oracle("report-v3.demo.json"); let report: Report = serde_json::from_value(parse_json(&source).unwrap()).unwrap(); assert_eq!(to_js_pretty(&report).unwrap(), expected); } #[test] fn the_v2_fixtures_and_the_migration_map_parse() { for name in ["report-v2.full.json", "report-v2.minimal.json"] { let (source, _) = common::zod_oracle(name); let parsed: Result = serde_json::from_value(parse_json(&source).unwrap()); assert!(parsed.is_ok(), "{name}: {parsed:?}"); } let (source, _) = common::zod_oracle("migration-map.draft.json"); let map: ReportMigrationMap = serde_json::from_value(parse_json(&source).unwrap()).unwrap(); assert!(map.annotations.len() > 20 && map.finding_paths.len() > 600); } #[test] fn the_frozen_envelopes_parse_and_print_as_their_attachment() { use faunosteo_core::domain::archive::ReportArchiveEnvelope; for name in ["demo", "v2full", "v2unresolved"] { let text = common::repo_file(&format!( "apps/app/tests/fixtures/goldens/r2/envelope.{name}.fr.nologos.json" )); let envelope: ReportArchiveEnvelope = serde_json::from_value(parse_json(&text).unwrap()).unwrap(); assert_eq!(to_js_pretty(&envelope).unwrap(), text, "{name}"); } }