use assert_cmd::Command;
use predicates::prelude::*;
fn project_with(file: &str, contents: &str) -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join(file), contents).unwrap();
dir
}
fn pinned_config(dir: &tempfile::TempDir) -> std::path::PathBuf {
let path = dir.path().join("pinned.toml");
std::fs::write(&path, "[hank.quipu]\nenabled = false\n").unwrap();
path
}
#[test]
fn status_json_reports_base_ref() {
let dir = tempfile::tempdir().unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--json", "--config"])
.arg(pinned_config(&dir))
.assert()
.success()
.stdout(predicate::str::contains("\"base_ref\""))
.stdout(predicate::str::contains("\"base_commit\""));
}
#[test]
fn analyze_counts_symbols() {
let dir = project_with("a.rs", "fn foo() {}\nstruct Bar;\n");
Command::cargo_bin("hank")
.unwrap()
.args(["analyze", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(predicate::str::contains("2 symbol"));
}
#[test]
fn refs_finds_definition() {
let dir = project_with("a.rs", "fn target() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "target", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(
predicate::str::contains("a.rs:1")
.and(predicate::str::contains("(function)"))
.and(predicate::str::contains("no definition found").not()),
);
}
#[test]
fn refs_json_contains_the_resolved_definition() {
let dir = project_with("a.rs", "fn target() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "target", dir.path().to_str().unwrap(), "--json"])
.assert()
.success()
.stdout(
predicate::str::contains("\"kind\"")
.and(predicate::str::contains("\"start_line\": 1"))
.and(predicate::str::contains("\"name\": \"target\"")),
);
}
#[test]
fn refs_json_absent_answer_is_tagged_and_says_what_it_searched() {
let dir = project_with("a.rs", "fn other() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "missing", dir.path().to_str().unwrap(), "--json"])
.assert()
.success()
.stdout(
predicate::str::contains("\"count\": 0")
.and(predicate::str::contains("\"tier\": \"treesitter\""))
.and(predicate::str::contains("\"searched_symbols\": 1")),
);
}
#[test]
#[cfg(feature = "langs-extra")] fn refs_resolves_a_python_definition_the_way_callers_does() {
let dir = project_with(
"quipu.py",
"def derive_agents(cfg):\n return cfg\n\ndef consume():\n return derive_agents({})\n",
);
let path = dir.path().to_str().unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "derive_agents", path])
.assert()
.success()
.stdout(
predicate::str::contains("quipu.py:1")
.and(predicate::str::contains("no definition found").not()),
);
Command::cargo_bin("hank")
.unwrap()
.args(["callers", "derive_agents", path])
.assert()
.success()
.stdout(predicate::str::contains("consume"));
}
#[test]
fn refs_does_not_report_an_unparseable_tree_as_an_absent_symbol() {
let dir = project_with("notes.md", "# nothing parseable here\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "anything", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(
predicate::str::contains("the graph is empty")
.and(predicate::str::contains("not evidence")),
);
}
#[test]
fn callers_lists_direct_callers() {
let dir = project_with("a.rs", "fn leaf() {}\nfn mid() { leaf(); }\n");
Command::cargo_bin("hank")
.unwrap()
.args(["callers", "leaf", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(predicate::str::contains("mid"));
}
#[test]
fn impact_reconciles_with_cochange() {
let dir = project_with(
"a.rs",
"fn leaf() {}\nfn mid() { leaf(); }\nfn top() { mid(); }\n",
);
std::fs::write(dir.path().join("cochange.json"), "[\"a.rs\", \"other.rs\"]").unwrap();
Command::cargo_bin("hank")
.unwrap()
.args([
"impact",
"leaf",
dir.path().to_str().unwrap(),
"--cochange",
dir.path().join("cochange.json").to_str().unwrap(),
"--json",
])
.assert()
.success()
.stdout(predicate::str::contains("\"reconciliation\""))
.stdout(predicate::str::contains("\"corroborated\""))
.stdout(predicate::str::contains("other.rs"));
}
#[test]
fn dataflow_traces_dependence() {
let dir = project_with(
"a.rs",
"fn f(a: i32) -> i32 { let b = a + 1; let c = b * 2; c }\n",
);
Command::cargo_bin("hank")
.unwrap()
.args([
"dataflow",
"f",
dir.path().to_str().unwrap(),
"--var",
"c",
"--json",
])
.assert()
.success()
.stdout(predicate::str::contains("\"b\""))
.stdout(predicate::str::contains("\"a\""));
}
#[test]
fn impact_reports_transitive_callers() {
let dir = project_with(
"a.rs",
"fn leaf() {}\nfn mid() { leaf(); }\nfn top() { mid(); }\n",
);
Command::cargo_bin("hank")
.unwrap()
.args([
"impact",
"leaf",
dir.path().to_str().unwrap(),
"--json",
"--hops",
"5",
])
.assert()
.success()
.stdout(predicate::str::contains("\"top\""))
.stdout(predicate::str::contains("\"count\": 2"));
}
fn guarded_project(policy: &str) -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("leaf.rs"), "fn leaf() {}\n").unwrap();
for i in 0..3 {
std::fs::write(
dir.path().join(format!("caller{i}.rs")),
format!("fn c{i}() {{ leaf(); }}\n"),
)
.unwrap();
}
let bobbin = dir.path().join(".bobbin");
std::fs::create_dir_all(&bobbin).unwrap();
std::fs::write(bobbin.join("config.toml"), policy).unwrap();
dir
}
fn pre_edit_payload(dir: &std::path::Path, file: &str, old: &str) -> String {
serde_json::json!({
"session_id": format!("it-{}-{file}", std::process::id()),
"cwd": dir.to_str().unwrap(),
"hook_event_name": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": dir.join(file).to_str().unwrap(),
"old_string": old,
"new_string": "fn leaf() { changed(); }",
},
})
.to_string()
}
#[test]
fn pre_edit_denies_an_edit_beyond_the_blast_radius() {
let dir = guarded_project(
"[hank.policy]\nmode = \"enforce\"\ndeadline_ms = 30000\n\
[hank.policy.scopes.polecat]\nmax_impacted_files = 1\n",
);
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}"))
.assert()
.success()
.stdout(predicate::str::contains("\"permissionDecision\":\"deny\""))
.stdout(predicate::str::contains("\"hookEventName\":\"PreToolUse\""))
.stdout(predicate::str::contains("3 files (ceiling 1)"));
}
#[test]
fn pre_edit_denies_a_path_outside_the_capability_scope() {
let dir = guarded_project(
"[hank.policy]\nmode = \"enforce\"\n\
[hank.policy.scopes.polecat]\nallow_paths = [\"caller*.rs\"]\n",
);
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}"))
.assert()
.success()
.stdout(predicate::str::contains("\"permissionDecision\":\"deny\""))
.stdout(predicate::str::contains(
"outside the writable capability scope",
));
}
#[test]
fn pre_edit_allows_an_ordinary_edit_silently() {
let dir = guarded_project(
"[hank.policy]\nmode = \"enforce\"\ndeadline_ms = 30000\n\
[hank.policy.scopes.polecat]\nmax_impacted_files = 10\n",
);
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}"))
.assert()
.success()
.stdout(predicate::str::is_empty());
}
#[test]
fn pre_edit_resolves_the_tenant_from_bobbin_role() {
let dir = guarded_project(
"[hank.policy]\nmode = \"enforce\"\n\
[hank.policy.scopes.polecat]\nallow_paths = [\"caller*.rs\"]\n",
);
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit"])
.env("BOBBIN_ROLE", "polecat")
.write_stdin(pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}"))
.assert()
.success()
.stdout(predicate::str::contains("\"permissionDecision\":\"deny\""));
}
#[test]
fn pre_edit_fails_open_on_garbage_and_on_no_policy() {
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin("not json at all")
.assert()
.success()
.stdout(predicate::str::is_empty());
let dir = project_with("a.rs", "fn foo() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(pre_edit_payload(dir.path(), "a.rs", "fn foo() {}"))
.assert()
.success()
.stdout(predicate::str::is_empty());
}
#[test]
fn pre_edit_never_denies_in_advise_mode() {
let dir = guarded_project(
"[hank.policy]\nmode = \"advise\"\ndeadline_ms = 30000\n\
[hank.policy.scopes.polecat]\nmax_impacted_files = 1\n",
);
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}"))
.assert()
.success()
.stdout(predicate::str::contains("systemMessage"))
.stdout(predicate::str::contains("not blocking"))
.stdout(predicate::str::contains("permissionDecision").not());
}
#[test]
fn verify_passes_a_clean_buffer_and_reports_its_tier() {
let dir = project_with("helpers.rs", "fn helper() {}\n");
let buffer = dir.path().join("proposed.rs");
std::fs::write(&buffer, "fn f() { helper(); }\n").unwrap();
Command::cargo_bin("hank")
.unwrap()
.current_dir(dir.path())
.args(["verify", "--file", "a.rs", "--buffer"])
.arg(&buffer)
.arg("--json")
.assert()
.success()
.stdout(predicate::str::contains("\"ok\": true"))
.stdout(predicate::str::contains(
"type-violation (needs the LSP tier)",
));
}
#[test]
fn verify_exits_nonzero_and_names_each_violation() {
let dir = project_with("helpers.rs", "fn helper() {}\n");
let buffer = dir.path().join("proposed.rs");
std::fs::write(
&buffer,
"fn takes_two(a: u8, b: u8) {}\nfn f() { takes_two(1); ghost(); }\nmod missing;\n",
)
.unwrap();
Command::cargo_bin("hank")
.unwrap()
.current_dir(dir.path())
.args(["verify", "--file", "a.rs", "--buffer"])
.arg(&buffer)
.arg("--json")
.assert()
.failure()
.stdout(predicate::str::contains("identifier-does-not-exist"))
.stdout(predicate::str::contains("wrong-arity"))
.stdout(predicate::str::contains("unresolved-import"));
}
#[test]
fn an_unknown_hook_event_fails_open_instead_of_exiting_2() {
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "some-event-this-hank-does-not-have"])
.write_stdin(r#"{"tool_name":"Edit","tool_input":{"file_path":"/tmp/x.rs"}}"#)
.assert()
.code(0)
.stdout(predicate::str::is_empty())
.stderr(predicate::str::contains("failed open"));
}
#[test]
fn a_non_hook_command_still_exits_2_on_bad_arguments() {
Command::cargo_bin("hank")
.unwrap()
.args(["definitely-not-a-command"])
.assert()
.code(2);
}
#[test]
fn hook_help_still_prints_and_exits_0() {
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "--help"])
.assert()
.code(0)
.stdout(predicate::str::contains("post-edit"));
}
#[test]
fn config_flag_makes_status_read_the_named_file() {
let dir = tempfile::tempdir().unwrap();
let bobbin = dir.path().join(".bobbin");
std::fs::create_dir_all(&bobbin).unwrap();
std::fs::write(
bobbin.join("config.toml"),
"[hank]\nbase_ref = \"from-cwd\"\n",
)
.unwrap();
let other = dir.path().join("other.toml");
std::fs::write(&other, "[hank]\nbase_ref = \"from-flag\"\n").unwrap();
Command::cargo_bin("hank")
.unwrap()
.current_dir(dir.path())
.args(["status", "--json", "--config"])
.arg(&other)
.assert()
.success()
.stdout(predicate::str::contains("from-flag"))
.stdout(predicate::str::contains("from-cwd").not());
}
#[test]
fn config_flag_points_the_guard_at_a_scope_file() {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("leaf.rs"), "fn leaf() {}\n").unwrap();
let scope = dir.path().join("scope.toml");
std::fs::write(
&scope,
"[hank.policy]\nmode = \"enforce\"\n\
[hank.policy.scopes.polecat]\nallow_paths = [\"src/**\"]\n",
)
.unwrap();
let payload = pre_edit_payload(dir.path(), "leaf.rs", "fn leaf() {}");
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat"])
.write_stdin(payload.clone())
.assert()
.success()
.stdout(predicate::str::is_empty());
Command::cargo_bin("hank")
.unwrap()
.args(["hook", "pre-edit", "--tenant", "polecat", "--config"])
.arg(&scope)
.write_stdin(payload)
.assert()
.success()
.stdout(predicate::str::contains("\"permissionDecision\":\"deny\""))
.stdout(predicate::str::contains(
"outside the writable capability scope",
));
}
#[test]
fn a_missing_config_path_is_a_loud_error_on_status() {
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--config", "/no/such/hank-config.toml"])
.assert()
.failure()
.stderr(predicate::str::contains("does not exist"));
}
#[test]
fn status_surfaces_policy_and_the_absent_signed_rule_set() {
let dir = tempfile::tempdir().unwrap();
let scope = dir.path().join("scope.toml");
std::fs::write(
&scope,
"[hank.policy]\nmode = \"enforce\"\n\
[hank.policy.scopes.weaver]\nallow_paths = [\"src/**\"]\nmax_impacted_files = 3\n",
)
.unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--json", "--tenant", "weaver", "--config"])
.arg(&scope)
.assert()
.success()
.stdout(predicate::str::contains("\"policy\""))
.stdout(predicate::str::contains("\"mode\": \"enforce\""))
.stdout(predicate::str::contains("\"scope_configured\": true"))
.stdout(predicate::str::contains("\"signed_rule_set\""))
.stdout(predicate::str::contains("\"never-loaded\""));
}
#[test]
fn status_warns_on_enforce_without_a_scope_for_the_tenant() {
let dir = tempfile::tempdir().unwrap();
let scope = dir.path().join("scope.toml");
std::fs::write(
&scope,
"[hank.policy]\nmode = \"enforce\"\n\
[hank.policy.scopes.someone_else]\nallow_paths = [\"src/**\"]\n",
)
.unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--json", "--tenant", "weaver", "--config"])
.arg(&scope)
.assert()
.success()
.stdout(predicate::str::contains(
"\"enforcing_without_scope\": true",
));
}
fn with_config(dir: &std::path::Path, body: &str) {
let bobbin = dir.join(".bobbin");
std::fs::create_dir_all(&bobbin).unwrap();
std::fs::write(bobbin.join("config.toml"), body).unwrap();
}
#[cfg(feature = "langs-extra")] #[test]
fn languages_restricts_what_analyze_counts() {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("a.rs"), "fn r(){}\nfn r2(){}\n").unwrap();
std::fs::write(
dir.path().join("b.py"),
"def p():\n pass\ndef p2():\n pass\n",
)
.unwrap();
std::fs::write(dir.path().join("c.ts"), "export function t(){}\n").unwrap();
let p = dir.path().to_str().unwrap();
with_config(dir.path(), "[hank]\nlanguages = [\"rust\"]\n");
Command::cargo_bin("hank")
.unwrap()
.args(["analyze", "--json", p])
.assert()
.success()
.stdout(predicate::str::contains("\"symbols\": 2"));
with_config(dir.path(), "[hank]\nlanguages = [\"rust\",\"python\"]\n");
Command::cargo_bin("hank")
.unwrap()
.args(["analyze", "--json", p])
.assert()
.success()
.stdout(predicate::str::contains("\"symbols\": 4"));
}
#[test]
fn serve_read_only_refuses_a_write() {
if !cfg!(feature = "quipu") {
return;
}
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("x.rs"), "fn x(){}\n").unwrap();
Command::new("git")
.arg("init")
.arg("-q")
.current_dir(dir.path())
.assert()
.success();
with_config(dir.path(), "[hank.serve]\nread_only = true\n");
Command::cargo_bin("hank")
.unwrap()
.arg("promote")
.current_dir(dir.path())
.assert()
.failure()
.stderr(predicate::str::contains("read_only"))
.stderr(predicate::str::contains("refused"));
with_config(dir.path(), "[hank.serve]\nread_only = false\n");
let assert = Command::cargo_bin("hank")
.unwrap()
.arg("promote")
.env("HOME", dir.path())
.current_dir(dir.path())
.assert();
assert
.failure()
.stderr(predicate::str::contains("--to").or(predicate::str::contains("endpoint")))
.stderr(predicate::str::contains("read_only").not());
}
#[test]
fn export_to_routes_through_promotion_not_print() {
let dir = tempfile::tempdir().unwrap();
std::fs::write(
dir.path().join("x.rs"),
"pub fn x() -> u32 { y() }\nfn y() -> u32 { 1 }\n",
)
.unwrap();
Command::cargo_bin("hank")
.unwrap()
.arg("export")
.current_dir(dir.path())
.assert()
.success()
.stdout(predicate::str::contains("bobbin:"))
.stdout(predicate::str::contains("CodeSymbol"));
let assert = Command::cargo_bin("hank")
.unwrap()
.args(["export", "--to", "http://127.0.0.1:1"])
.current_dir(dir.path())
.assert();
if cfg!(feature = "quipu") {
assert
.failure()
.stdout(predicate::str::contains("bobbin:").not());
} else {
assert
.failure()
.stderr(predicate::str::contains("--features quipu"));
}
}
#[test]
fn promote_refuses_dir_name_identity_and_accepts_origin() {
if !cfg!(feature = "quipu") {
return; }
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("x.rs"), "pub fn x() -> u32 { 1 }\n").unwrap();
for args in [
&["init", "-q"][..],
&["config", "user.email", "t@t"],
&["config", "user.name", "t"],
&["add", "-A"],
&["commit", "-qm", "base"],
] {
Command::new("git")
.args(args)
.current_dir(dir.path())
.assert()
.success();
}
Command::cargo_bin("hank")
.unwrap()
.args(["promote", "--to", "http://127.0.0.1:1"])
.current_dir(dir.path())
.assert()
.failure()
.stderr(predicate::str::contains("--repo"))
.stderr(predicate::str::contains("repository identity"));
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
let server = std::thread::spawn(move || {
if let Ok((mut sock, _)) = listener.accept() {
use std::io::{Read, Write};
let mut buf = [0u8; 4096];
let _ = sock.read(&mut buf);
let _ = sock.write_all(b"HTTP/1.1 400 Bad Request\r\ncontent-length: 0\r\n\r\n");
}
});
Command::new("git")
.args([
"remote",
"add",
"origin",
"https://example.com/owner/realname.git",
])
.current_dir(dir.path())
.assert()
.success();
Command::cargo_bin("hank")
.unwrap()
.args(["promote", "--to", &format!("http://{addr}")])
.current_dir(dir.path())
.assert()
.failure()
.stderr(predicate::str::contains("repository identity").not())
.stderr(predicate::str::contains("status 400"));
server.join().unwrap();
}
#[test]
fn refs_at_a_position_resolves_one_symbol_where_the_name_resolves_many() {
let dir = project_with(
"a.rs",
"struct Alpha;\nimpl Alpha {\n fn build() -> Self { Alpha }\n}\n\
struct Beta;\nimpl Beta {\n fn build() -> Self { Beta }\n}\n",
);
let path = dir.path().to_str().unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "build", path])
.assert()
.success()
.stdout(predicate::str::contains("a.rs:3").and(predicate::str::contains("a.rs:7")));
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "--at", "a.rs:7", path])
.assert()
.success()
.stdout(predicate::str::contains("a.rs:7").and(predicate::str::contains("a.rs:3").not()));
}
#[test]
fn refs_at_refuses_a_column_rather_than_resolving_it_as_a_line() {
let dir = project_with("a.rs", "fn one() {}\nfn two() {}\nfn three() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "--at", "a.rs:3:9", dir.path().to_str().unwrap()])
.assert()
.failure()
.stderr(
predicate::str::contains("FILE:LINE:COL")
.and(predicate::str::contains("LSP tier"))
.and(predicate::str::contains("a.rs:3")),
);
}
#[test]
fn refs_at_a_line_between_definitions_explains_instead_of_answering_absent() {
let dir = project_with("a.rs", "fn one() {}\n\n\n\nfn two() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "--at", "a.rs:3", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(
predicate::str::contains("no symbol encloses a.rs:3")
.and(predicate::str::contains("between definitions"))
.and(predicate::str::contains("one"))
.and(predicate::str::contains("two")),
);
}
#[test]
fn refs_at_an_unparseable_file_says_so_rather_than_reporting_no_definitions() {
let dir = project_with("a.rs", "fn one() {}\n");
Command::cargo_bin("hank")
.unwrap()
.args(["refs", "--at", "nope.rs:1", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(predicate::str::contains(
"no symbols in the graph for `nope.rs`",
));
}
#[cfg(feature = "quipu")]
#[test]
fn status_exits_nonzero_when_the_rule_plane_is_degraded() {
let dir = tempfile::tempdir().unwrap();
let cfg = dir.path().join("dead.toml");
std::fs::write(
&cfg,
"[hank.quipu]\nenabled = true\nendpoint = \"http://127.0.0.1:59999\"\n",
)
.unwrap();
let assert = Command::cargo_bin("hank")
.unwrap()
.args(["status", "--config"])
.arg(&cfg)
.assert()
.code(3);
assert.stdout(predicate::str::contains("FAILING OPEN"));
}
#[cfg(feature = "quipu")]
#[test]
fn a_degraded_plane_is_not_an_empty_one() {
let dir = tempfile::tempdir().unwrap();
let dead = dir.path().join("dead.toml");
std::fs::write(
&dead,
"[hank.quipu]\nenabled = true\nendpoint = \"http://127.0.0.1:59999\"\n",
)
.unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--json", "--config"])
.arg(&dead)
.assert()
.code(3)
.stdout(predicate::str::contains("\"state\": \"degraded\""))
.stdout(predicate::str::contains("\"attempts\": 3"))
.stdout(predicate::str::contains("\"digest\": null"));
let off = dir.path().join("off.toml");
std::fs::write(&off, "[hank.quipu]\nenabled = false\n").unwrap();
Command::cargo_bin("hank")
.unwrap()
.args(["status", "--json", "--config"])
.arg(&off)
.assert()
.success()
.stdout(predicate::str::contains("\"state\": \"off\""))
.stdout(predicate::str::contains("\"verification\": \"unsigned\""));
}