use assert_cmd::Command;
#[test]
fn help_lists_all_flags() {
let mut cmd = Command::cargo_bin("atproto-devtool").expect("bin not found");
let output = cmd
.arg("test")
.arg("labeler")
.arg("--help")
.output()
.expect("failed to run atproto-devtool");
assert!(
output.status.success(),
"--help should exit successfully, got {:?}",
output.status,
);
let stdout = String::from_utf8_lossy(&output.stdout);
for needle in [
"--did",
"--subscribe-timeout",
"--verbose",
"--no-color",
"<TARGET>",
] {
assert!(
stdout.contains(needle),
"--help stdout missing expected token `{needle}`, got:\n{stdout}",
);
}
}
#[test]
fn bootstrap_failure_exits_two() {
let mut cmd = Command::cargo_bin("atproto-devtool").expect("bin not found");
let assert = cmd.arg("test").arg("labeler").assert();
assert.code(2);
}
#[test]
fn no_color_renders_without_ansi() {
let mut cmd = Command::cargo_bin("atproto-devtool").expect("bin not found");
cmd.env_remove("NO_COLOR");
cmd.arg("test")
.arg("labeler")
.arg("--no-color")
.arg("did:web:nonexistent.invalid");
let output = cmd.output().expect("failed to run atproto-devtool");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
!stdout.contains("\x1b["),
"Stdout must not contain ANSI escape sequences with --no-color, got:\n{stdout}",
);
assert!(
stdout.contains("== Identity =="),
"Stdout should contain a rendered identity section, got:\n{stdout}",
);
assert!(
stdout.contains("[FAIL]") || stdout.contains("[NET]"),
"Stdout should contain at least one failure or network-error check glyph, got:\n{stdout}",
);
}
#[test]
fn verbose_flag_emits_debug_tracing_to_stderr() {
let mut cmd = Command::cargo_bin("atproto-devtool").expect("bin not found");
cmd.arg("test")
.arg("labeler")
.arg("--verbose")
.arg("--no-color")
.arg("did:web:nonexistent.invalid");
let output = cmd.output().expect("failed to run atproto-devtool");
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("DEBUG"),
"Stderr should contain DEBUG tracing output with --verbose, got:\n{stderr}",
);
}