mod common;
use common::grex;
use predicates::prelude::*;
#[test]
fn add_with_url_only_succeeds() {
let dir = tempfile::tempdir().unwrap();
grex()
.current_dir(dir.path())
.args(["add", "https://example.com/repo.git"])
.assert()
.success()
.stdout(predicate::str::contains("added"));
}
#[test]
fn add_with_url_and_path_succeeds() {
let dir = tempfile::tempdir().unwrap();
grex()
.current_dir(dir.path())
.args(["add", "https://example.com/repo.git", "my-path"])
.assert()
.success()
.stdout(predicate::str::contains("my-path"));
}
#[test]
fn add_with_no_url_fails() {
grex().arg("add").assert().failure();
}
#[test]
fn rm_with_path_succeeds() {
grex()
.args(["rm", "my-pack"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn rm_without_path_fails() {
grex().arg("rm").assert().failure();
}
#[test]
fn update_without_pack_succeeds() {
grex().arg("update").assert().success().stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn update_with_pack_succeeds() {
grex()
.args(["update", "my-pack"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn run_with_action_succeeds() {
grex()
.args(["run", "symlink"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn run_without_action_fails() {
grex().arg("run").assert().failure();
}
#[test]
fn exec_with_trailing_args_succeeds() {
grex()
.args(["exec", "echo", "hi", "there"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn exec_with_single_arg_succeeds() {
grex()
.args(["exec", "echo"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn exec_without_args_currently_succeeds() {
grex().arg("exec").assert().success().stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn add_empty_url_currently_succeeds() {
let dir = tempfile::tempdir().unwrap();
grex()
.current_dir(dir.path())
.args(["add", "", "--dry-run"])
.assert()
.success()
.stdout(predicate::str::contains("DRY-RUN: would add"));
}
#[test]
fn rm_unicode_path_succeeds() {
grex()
.args(["rm", "unicode-пакет-🎯"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn rm_long_path_succeeds() {
let long = "a".repeat(512);
grex()
.args(["rm", long.as_str()])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[cfg(windows)]
#[test]
fn import_with_windows_drive_path_parses() {
grex()
.args(["import", "--from-repos-json", r"C:\temp\does-not-exist\REPOS.json"])
.assert()
.failure();
}
#[cfg(windows)]
#[test]
fn rm_with_windows_relative_path_succeeds() {
grex()
.args(["rm", r".\pack"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[cfg(windows)]
#[test]
fn rm_with_windows_parent_relative_path_succeeds() {
grex()
.args(["rm", r"..\pack"])
.assert()
.success()
.stdout(predicate::str::contains("unimplemented"));
}
#[test]
fn import_with_no_flag_fails_with_message() {
let out = grex().arg("import").assert().failure().get_output().stderr.clone();
let s = String::from_utf8(out).unwrap();
assert!(s.contains("--from-repos-json"), "expected missing-flag message, got: {s}");
}
#[test]
fn import_with_from_repos_json_relative_path_parses() {
grex().args(["import", "--from-repos-json", "./does-not-exist.json"]).assert().failure();
}
#[test]
fn sync_default_emits_usage_error() {
grex()
.arg("sync")
.assert()
.failure()
.code(2)
.stderr(predicate::str::contains("grex sync:").and(predicate::str::contains("pack_root")));
}
#[test]
fn sync_recursive_explicit_true_parses() {
grex()
.args(["sync", "--recursive"])
.assert()
.failure()
.code(2)
.stderr(predicate::str::contains("grex sync:"));
}