summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-29 14:16:06 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-29 14:16:06 +0200
commitff2a4b09646a8a5949808bfadf31747751831963 (patch)
treeb5db991f6829d2f9564bf5bb915176b4f978c63c /tests
parent2e84602de722694c5cce4172e7455f592cee6a03 (diff)
Function to get the current user's groups
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 1daa850..872c2ce 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -2,7 +2,7 @@ use anyhow::Result;
use assert_cmd::{cargo::cargo_bin, Command};
use rexpect::session::{spawn_command, PtySession};
use tempfile::TempDir;
-use user_info::get_username;
+use user_info::{get_user_groups, get_username};
struct TestContext {
p: PtySession,
@@ -107,7 +107,7 @@ fn can_init_a_new_git_repo() -> Result<()> {
.as_ref()
.join("git")
.join(username)
- .join("my-new-repo.git"),
+ .join(&format!("{}.git", repo_name)),
)
.assert()
.success()
@@ -116,6 +116,36 @@ fn can_init_a_new_git_repo() -> Result<()> {
}
#[test]
+#[ignore]
+fn can_init_a_new_shared_git_repo() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ let group = get_user_groups().pop().unwrap();
+ let repo_name = "my-new-shared-repo";
+ c.p.send_line(&format!("git-init --shared {} {}", group, repo_name))?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{}/{}.git\"",
+ group, repo_name
+ ))?;
+ expect_prompt(&mut c.p)?;
+
+ Command::new("git")
+ .arg("rev-list")
+ .arg("--all")
+ .current_dir(
+ c.workdir
+ .as_ref()
+ .join("git")
+ .join(&group)
+ .join(&format!("{}.git", repo_name)),
+ )
+ .assert()
+ .success()
+ .stdout("");
+ // TODO: Check file permissions? Shared set in git config?
+ Ok(())
+}
+
+#[test]
fn runs_a_single_command_and_exit_with_cli_flag() -> Result<()> {
let username = get_username().unwrap();
let repo_name = "another-new-repo";