use gitea_pr_review::model::{ CommentItem, CommentThread, DiffStat, FileStat, PrMeta, PrReviewDocument, }; #[test] fn model_json_roundtrip() { let doc = PrReviewDocument { meta: PrMeta { repo: "org/repo".into(), pr_index: 9, title: "feat: x".into(), state: "open".into(), author: "alice".into(), base_branch: "main".into(), head_branch: "feature/x".into(), created_at: "2026-04-08T10:00:00Z".into(), updated_at: "2026-04-08T11:00:00Z".into(), merged_at: None, }, commits: vec![], diff_stat: DiffStat { files_changed: 1, additions: 2, deletions: 1, files: vec![FileStat { path: "src/main.rs".into(), additions: 2, deletions: 1, }], }, reviews: vec![], threads: vec![CommentThread { thread_id: "t1".into(), file_path: Some("src/main.rs".into()), line: Some(10), root_comment: CommentItem { id: 100, user: "reviewer".into(), created_at: "2026-04-08T12:00:00Z".into(), body: "hello".into(), }, replies: vec![], }], }; let encoded = serde_json::to_string(&doc).unwrap(); let decoded: PrReviewDocument = serde_json::from_str(&encoded).unwrap(); assert_eq!(decoded.meta.repo, "org/repo"); assert_eq!(decoded.threads[0].root_comment.body, "hello"); }