mod common;
use common::{suno, suno_in};
#[test]
fn contract_exit_0() {
suno().args(["contract", "0"]).assert().code(0);
}
#[test]
fn contract_exit_1_transient() {
suno().args(["contract", "1"]).assert().code(1);
}
#[test]
fn contract_exit_2_config() {
suno().args(["contract", "2"]).assert().code(2);
}
#[test]
fn contract_exit_3_bad_input() {
suno().args(["contract", "3"]).assert().code(3);
}
#[test]
fn contract_exit_4_rate_limited() {
suno().args(["contract", "4"]).assert().code(4);
}
#[test]
fn contract_unknown_code_is_bad_input() {
suno().args(["contract", "5"]).assert().code(3);
}
#[test]
fn help_exits_0() {
suno().arg("--help").assert().code(0);
}
#[test]
fn version_exits_0() {
suno().arg("--version").assert().code(0);
}
#[test]
fn missing_subcommand_exits_3() {
suno().assert().code(3);
}
#[test]
fn unknown_flag_exits_3() {
suno()
.args(["list", "--definitely-not-a-flag"])
.assert()
.code(3);
}
#[test]
fn status_without_ids_exits_3() {
suno().arg("status").assert().code(3);
}
#[test]
fn download_without_ids_exits_3() {
suno().arg("download").assert().code(3);
}
#[test]
fn publish_without_ids_exits_3() {
suno().arg("publish").assert().code(3);
}
#[test]
fn stems_wait_flag_removed_exits_3() {
suno().args(["stems", "abc", "--wait"]).assert().code(3);
}
#[test]
fn concat_wait_flag_removed_exits_3() {
suno().args(["concat", "abc", "--wait"]).assert().code(3);
}
#[test]
fn agent_info_exits_0() {
suno().arg("agent-info").assert().code(0);
}
#[test]
fn config_show_and_path_exit_0() {
let tmp = tempfile::tempdir().unwrap();
suno_in(tmp.path())
.args(["config", "show"])
.assert()
.code(0);
suno_in(tmp.path())
.args(["config", "path"])
.assert()
.code(0);
}
#[test]
fn doctor_without_auth_exits_2() {
let tmp = tempfile::tempdir().unwrap();
let out = suno_in(tmp.path()).arg("doctor").output().unwrap();
assert_eq!(out.status.code(), Some(2));
let report: serde_json::Value = serde_json::from_slice(&out.stdout).unwrap();
assert_eq!(report["status"], "partial_success");
assert!(report["data"]["checks"].is_array());
let auth_check = report["data"]["checks"]
.as_array()
.unwrap()
.iter()
.find(|c| c["name"] == "auth_file")
.expect("doctor must include an auth_file check");
assert_eq!(auth_check["status"], "fail");
}