use assert_cmd::Command;
use predicates::str;
fn bin() -> Command {
Command::cargo_bin("shuire").expect("binary should be built")
}
#[test]
fn prints_help() {
bin()
.arg("--help")
.assert()
.success()
.stdout(str::contains("Vim-like TUI git diff viewer"));
}
#[test]
fn prints_version() {
bin()
.arg("--version")
.assert()
.success()
.stdout(str::contains(env!("CARGO_PKG_VERSION")));
}
#[test]
fn rejects_conflicting_flags() {
bin()
.args(["--pr", "https://github.com/example/repo/pull/1", "main"])
.assert()
.failure()
.stderr(str::contains("--pr cannot be combined with positional"));
}
#[test]
fn rejects_merge_base_without_base() {
bin()
.args(["--merge-base", "main"])
.assert()
.failure()
.stderr(str::contains("--merge-base requires"));
}
#[test]
fn rejects_from_file_with_pr() {
bin()
.args([
"--from-file",
"/tmp/nonexistent.diff",
"--pr",
"https://github.com/example/repo/pull/1",
])
.assert()
.failure();
}
#[test]
fn rejects_invalid_commitish() {
bin()
.args(["--", "HEAD.."])
.assert()
.failure()
.stderr(str::contains("Invalid target commit-ish"));
}
#[test]
fn rejects_working_versus_commit() {
bin()
.args(["working", "main"])
.assert()
.failure()
.stderr(str::contains("\"working\" shows unstaged changes"));
}
#[test]
fn rejects_target_equals_base() {
bin()
.args(["main", "main"])
.assert()
.failure()
.stderr(str::contains("Cannot compare main with itself"));
}