//! Contract tests to verify our types can parse real CLI outputs //! //! These tests use fixtures captured from actual CLI commands to ensure //! our Rust types stay in sync with the CLI output format. use mission_control_lib::data::lore::LoreMeResponse; use mission_control_lib::data::beads::Bead; /// Test that we can deserialize empty lore response #[test] fn parse_lore_me_empty_fixture() { let fixture = include_str!("fixtures/lore/me_empty.json"); let result: Result = serde_json::from_str(fixture); assert!(result.is_ok(), "Failed to parse me_empty.json: {:?}", result.err()); let response = result.unwrap(); assert!(response.ok); assert!(response.data.open_issues.is_empty()); assert!(response.data.open_mrs_authored.is_empty()); assert!(response.data.reviewing_mrs.is_empty()); } /// Test that we can deserialize real lore response with activity /// /// This test may fail if the fixture format changes. Run: /// ./scripts/regenerate-fixtures.sh /// to update the fixtures if the CLI output format changes. #[test] fn parse_lore_me_with_activity_fixture() { let fixture = include_str!("fixtures/lore/me_with_activity.json"); let result: Result = serde_json::from_str(fixture); // If this fails, run: ./scripts/regenerate-fixtures.sh assert!(result.is_ok(), "Failed to parse me_with_activity.json: {:?}", result.err()); let response = result.unwrap(); assert!(response.ok); } /// Test that we can deserialize empty beads list #[test] fn parse_br_list_empty_fixture() { let fixture = include_str!("fixtures/br/list_empty.json"); let result: Result, _> = serde_json::from_str(fixture); assert!(result.is_ok(), "Failed to parse list_empty.json: {:?}", result.err()); assert!(result.unwrap().is_empty()); } /// Test that we can deserialize real beads list with entries #[test] fn parse_br_list_with_beads_fixture() { let fixture = include_str!("fixtures/br/list_with_beads.json"); let result: Result, _> = serde_json::from_str(fixture); // If this fails, run: ./scripts/regenerate-fixtures.sh assert!(result.is_ok(), "Failed to parse list_with_beads.json: {:?}", result.err()); let beads = result.unwrap(); assert!(!beads.is_empty()); // Verify first bead has expected fields let first = &beads[0]; assert!(!first.id.is_empty()); assert!(!first.title.is_empty()); assert!(!first.status.is_empty()); }