summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-20 23:18:41 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-20 23:18:41 +0200
commit2b827a0ab06fb715290a0450a3fff56d3e6f4ee6 (patch)
treeb5e24df3fa573afd07b55a2330e88cabe2394e3f /tests
parentae4b23d95dc8792231c1e8212978be8305ee1964 (diff)
Put git repos into a user-specific dir
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs39
-rw-r--r--tests/server_shell.rs3
2 files changed, 34 insertions, 8 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index e6a59b3..a370154 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -1,6 +1,7 @@
use anyhow::Result;
use assert_cmd::{cargo::cargo_bin, Command};
use rexpect::session::{spawn_command, PtySession};
+use shackle::user::get_username;
use tempfile::TempDir;
struct TestContext {
@@ -89,14 +90,25 @@ fn reports_error_with_nonsense_input() -> Result<()> {
#[test]
fn can_init_a_new_git_repo() -> Result<()> {
let mut c = spawn_interactive_process()?;
- c.p.send_line("git-init my-new-repo")?;
- c.p.exp_string("Successfully created \"my-new-repo.git\"")?;
+ let username = get_username().unwrap();
+ let repo_name = "my-new-repo";
+ c.p.send_line(&format!("git-init {}", repo_name))?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{}/{}.git\"",
+ username, repo_name
+ ))?;
expect_prompt(&mut c.p)?;
Command::new("git")
.arg("rev-list")
.arg("--all")
- .current_dir(c.workdir.as_ref().join("git").join("my-new-repo.git"))
+ .current_dir(
+ c.workdir
+ .as_ref()
+ .join("git")
+ .join(username)
+ .join("my-new-repo.git"),
+ )
.assert()
.success()
.stdout("");
@@ -105,17 +117,26 @@ fn can_init_a_new_git_repo() -> Result<()> {
#[test]
fn runs_a_single_command_and_exit_with_cli_flag() -> Result<()> {
- let mut c = run_batch_command("git-init another-new-repo")?;
- c.p.exp_string("Successfully created \"another-new-repo.git\"")?;
+ let username = get_username().unwrap();
+ let repo_name = "another-new-repo";
+ let mut c = run_batch_command(&format!("git-init {}", repo_name))?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{}/{}.git\"",
+ username, repo_name
+ ))?;
c.p.exp_eof()?;
Ok(())
}
#[test]
fn allows_quotes_arguments() -> Result<()> {
+ let username = get_username().unwrap();
let mut c = spawn_interactive_process()?;
c.p.send_line("\"git-init\" 'another-new-repo'")?;
- c.p.exp_string("Successfully created \"another-new-repo.git\"")?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{}/another-new-repo.git\"",
+ username
+ ))?;
Ok(())
}
@@ -137,8 +158,12 @@ fn errors_with_an_open_single_quote() -> Result<()> {
#[test]
fn allows_single_quotes_and_spaces_inside_double_quotes() -> Result<()> {
+ let username = get_username().unwrap();
let mut c = spawn_interactive_process()?;
c.p.send_line("git-init \"shukkie's new repo\"")?;
- c.p.exp_string("Successfully created \"shukkie's new repo.git\"")?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{}/shukkie's new repo.git\"",
+ username
+ ))?;
Ok(())
}
diff --git a/tests/server_shell.rs b/tests/server_shell.rs
index c87fb53..72329d3 100644
--- a/tests/server_shell.rs
+++ b/tests/server_shell.rs
@@ -166,7 +166,7 @@ fn clone_git_repo(c: &TestContext, path: &str) -> Assert {
}
fn clone_git_repo_relative_path(c: &TestContext, repo_name: &str) -> Assert {
- clone_git_repo(c, &format!("/home/shukkie/git/{}.git", repo_name))
+ clone_git_repo(c, &format!("/home/shukkie/git/shukkie/{}.git", repo_name))
}
#[test]
@@ -215,6 +215,7 @@ fn git_push_works() -> Result<()> {
}
#[test]
+#[ignore = "Need to put the repo in the right dir first"]
fn git_clone_can_not_target_repo_outside_allowed_paths() -> Result<()> {
let c = spawn_ssh_server()?;
clone_git_repo(&c, "/home/shukkie/disallowed.git")