summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-08-11 22:04:19 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-08-15 21:40:35 +0200
commit64da82c661b2a28c7a258bd30c0084633d0e1896 (patch)
treee631e496b70f10d8414a3d1962797aa6354de918 /tests
parent2203a06532979e8c4772dcb134c109e1f308031a (diff)
Create group directories if they don't already exist
- With the correct ownership - With the correct permissions Fix #5
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs18
-rw-r--r--tests/cli_test_utils/context.rs8
2 files changed, 22 insertions, 4 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 01c3347..34249c2 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -2,6 +2,7 @@ mod cli_test_utils;
use anyhow::Result;
use cli_test_utils::*;
+use std::os::unix::fs::MetadataExt;
const REPO_NAME: &str = "my-repository";
const REPO_NAME_2: &str = "my-other-repository";
@@ -83,6 +84,23 @@ fn can_init_a_new_shared_git_repo() -> Result<()> {
verify_repo_exists(&repo_dir);
verify_repo_config_value(&repo_dir, "core.sharedrepository", Some("1"));
+ let expected_gid = nix::unistd::Group::from_name(&group)
+ .unwrap()
+ .unwrap()
+ .gid
+ .as_raw();
+ let group_dir = repo_dir.parent().unwrap();
+ let group_dir_metadata = group_dir.metadata().unwrap();
+ assert_eq!(group_dir_metadata.gid(), expected_gid);
+ assert_eq!(
+ group_dir_metadata.mode(),
+ 0o42770,
+ "Mode is {:o}",
+ group_dir_metadata.mode()
+ );
+
+ assert_eq!(repo_dir.metadata().unwrap().gid(), expected_gid);
+
Ok(())
}
diff --git a/tests/cli_test_utils/context.rs b/tests/cli_test_utils/context.rs
index 2517040..2c61085 100644
--- a/tests/cli_test_utils/context.rs
+++ b/tests/cli_test_utils/context.rs
@@ -100,15 +100,15 @@ impl TestContext {
}
}
+pub fn arbitrary_user_group() -> String {
+ get_user_groups().into_iter().next().unwrap()
+}
+
pub fn personal_repo_path(repo_name: &str) -> String {
let username = get_username().unwrap();
format!("git/{username}/{repo_name}.git")
}
-pub fn arbitrary_user_group() -> String {
- get_user_groups().into_iter().next().unwrap()
-}
-
pub fn group_repo_path(group: &str, repo_name: &str) -> String {
format!("git/{group}/{repo_name}.git")
}