Skip to content

Commit 50f3e94

Browse files
Add report regression coverage
* Add report regression coverage * Improve report regression diagnostics
1 parent f1f7197 commit 50f3e94

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

tests/cli.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use assert_cmd::Command;
22
use predicates::str::contains;
3+
use serde_json::Value;
34
use std::fs;
45

56
#[test]
@@ -136,6 +137,32 @@ fn review_pack_outputs_json() {
136137
.stdout(contains("\"tx-psbt-counts-match\""));
137138
}
138139

140+
#[test]
141+
fn review_pack_json_is_parseable_with_stable_schema() {
142+
let report = json_stdout([
143+
"review-pack",
144+
"--input",
145+
"tests/fixtures/review-packs/complete",
146+
"--format",
147+
"json",
148+
]);
149+
150+
assert_eq!(report["schema_version"], "0.4");
151+
assert!(
152+
report
153+
.get("artifacts_detected")
154+
.and_then(Value::as_array)
155+
.expect("artifacts_detected should be an array")
156+
.len()
157+
>= 4
158+
);
159+
assert!(!report
160+
.get("review_questions")
161+
.and_then(Value::as_array)
162+
.expect("review_questions should be an array")
163+
.is_empty());
164+
}
165+
139166
#[test]
140167
fn review_pack_outputs_markdown_file() {
141168
let temp_dir = tempfile::tempdir().unwrap();
@@ -181,6 +208,36 @@ fn policy_pack_outputs_json() {
181208
.stdout(contains("\"descriptor-psbt-multisig-mismatch\""));
182209
}
183210

211+
#[test]
212+
fn policy_pack_json_is_parseable_with_stable_schema() {
213+
let report = json_stdout([
214+
"policy-pack",
215+
"--input",
216+
"tests/fixtures/policy-packs/multisig-timelock",
217+
"--format",
218+
"json",
219+
]);
220+
221+
assert_eq!(report["schema_version"], "0.5");
222+
assert_eq!(report["pack_type"], "policy_pack");
223+
assert!(!report
224+
.get("evidence_documents")
225+
.and_then(Value::as_array)
226+
.expect("evidence_documents should be an array")
227+
.is_empty());
228+
assert!(!report
229+
.get("missing_evidence")
230+
.and_then(Value::as_array)
231+
.expect("missing_evidence should be an array")
232+
.is_empty());
233+
}
234+
235+
fn json_stdout<const N: usize>(args: [&str; N]) -> Value {
236+
let mut cmd = Command::cargo_bin("btc-risk-lab").unwrap();
237+
let assert = cmd.args(args).assert().success();
238+
serde_json::from_slice(&assert.get_output().stdout).expect("stdout should be valid JSON")
239+
}
240+
184241
#[test]
185242
fn policy_pack_outputs_markdown_file() {
186243
let temp_dir = tempfile::tempdir().unwrap();

0 commit comments

Comments
 (0)