feat: enforce output version v1 and add version subcommand

This commit is contained in:
2026-04-08 23:59:55 +08:00
parent a6daaff0fa
commit c4fa0eadcc
14 changed files with 117 additions and 10 deletions
+4 -2
View File
@@ -5,12 +5,13 @@ use gitea_pr_review::model::{
#[test]
fn model_json_roundtrip() {
let doc = PrReviewDocument {
version: "v1".into(),
meta: PrMeta {
repo: "org/repo".into(),
pr_index: 9,
title: "feat: x".into(),
description: Some("desc".into()),
fetched_at: Some("2026-04-08T12:34:56Z".into()),
fetched_at: "2026-04-08T12:34:56Z".into(),
state: "open".into(),
author: "alice".into(),
base_branch: "main".into(),
@@ -50,7 +51,8 @@ fn model_json_roundtrip() {
let encoded = serde_json::to_string(&doc).unwrap();
let decoded: PrReviewDocument = serde_json::from_str(&encoded).unwrap();
assert_eq!(decoded.version, "v1");
assert_eq!(decoded.meta.repo, "org/repo");
assert_eq!(decoded.meta.fetched_at.as_deref(), Some("2026-04-08T12:34:56Z"));
assert_eq!(decoded.meta.fetched_at, "2026-04-08T12:34:56Z");
assert_eq!(decoded.threads[0].root_comment.body, "hello");
}