summaryrefslogtreecommitdiff
path: root/tests/cli_test_utils/git.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cli_test_utils/git.rs')
-rw-r--r--tests/cli_test_utils/git.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/cli_test_utils/git.rs b/tests/cli_test_utils/git.rs
new file mode 100644
index 0000000..d3f35c4
--- /dev/null
+++ b/tests/cli_test_utils/git.rs
@@ -0,0 +1,41 @@
+use assert_cmd::Command;
+use std::path::Path;
+
+pub fn verify_repo_exists(repo_dir: &Path) {
+ Command::new("git")
+ .arg("rev-list")
+ .arg("--all")
+ .current_dir(repo_dir)
+ .assert()
+ .success()
+ .stdout("");
+}
+
+pub fn verify_repo_does_not_exist(repo_dir: &Path) {
+ assert!(!repo_dir.exists());
+}
+
+pub fn verify_current_branch(repo_dir: &Path, expected_ref: &str) {
+ Command::new("git")
+ .arg("symbolic-ref")
+ .arg("HEAD")
+ .current_dir(repo_dir)
+ .assert()
+ .success()
+ .stdout(format!("{expected_ref}\n"));
+}
+
+pub fn verify_repo_config_value(repo_dir: &Path, config_key: &str, config_value: Option<&str>) {
+ let assert = Command::new("git")
+ .args(["config", "--local", config_key])
+ .current_dir(repo_dir)
+ .assert();
+ match config_value {
+ Some(value) => {
+ assert.success().stdout(format!("{value}\n"));
+ }
+ None => {
+ assert.failure().code(1);
+ }
+ }
+}