use plexus_core::plexus::schema::PluginSchema;
const SOLAR_GOLDEN: &str = include_str!("golden/solar.json");
#[test]
fn ir4_solar_schema_is_byte_identical_roundtrip() {
let schema: PluginSchema =
serde_json::from_str(SOLAR_GOLDEN).expect("Solar golden JSON deserializes");
let re_serialized =
serde_json::to_string_pretty(&schema).expect("Solar schema re-serializes");
let expected = SOLAR_GOLDEN.trim_end_matches('\n');
let actual = re_serialized.trim_end_matches('\n');
if expected != actual {
eprintln!("--- golden (expected) ---\n{expected}\n");
eprintln!("--- produced (actual) ---\n{actual}\n");
panic!("Solar golden snapshot mismatch — IR-4 changed PluginSchema wire format");
}
}
#[test]
#[allow(deprecated)]
fn ir4_solar_is_hub_matches_is_hub_by_role() {
let schema: PluginSchema =
serde_json::from_str(SOLAR_GOLDEN).expect("Solar golden JSON deserializes");
assert_eq!(
schema.is_hub(),
schema.is_hub_by_role(),
"is_hub() and is_hub_by_role() must agree on Solar's schema"
);
assert!(schema.is_hub_by_role(), "Solar is a hub");
}
#[test]
#[allow(deprecated)]
fn ir4_solar_children_preserved_alongside_role_tagged_method() {
let schema: PluginSchema =
serde_json::from_str(SOLAR_GOLDEN).expect("Solar golden JSON deserializes");
let kids = schema.children.as_ref().expect("Solar is a hub");
assert_eq!(kids.len(), 8, "Solar has 8 planets");
let body_method = schema
.methods
.iter()
.find(|m| m.name == "body")
.expect("Solar exposes a `body` method");
use plexus_core::MethodRole;
assert!(
matches!(body_method.role, MethodRole::DynamicChild { .. }),
"Solar's `body` method must carry DynamicChild role; got {:?}",
body_method.role
);
}