Skip to content

Commit 3f54ade

Browse files
committed
First test to validate how collisions are expressed. (#595)
Right now they only appear to be locks already taken, not the best UX for sure, but a starting point.
1 parent 063ab73 commit 3f54ade

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

git-ref/tests/file/transaction/prepare_and_commit/create_or_update.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,31 @@ use crate::file::{
2424
mod collisions {
2525
use crate::file::transaction::prepare_and_commit::{create_at, empty_store};
2626
use git_lock::acquire::Fail;
27-
use git_testtools::once_cell::sync::Lazy;
2827

29-
static CASE_SENSITIVE: Lazy<bool> =
30-
Lazy::new(|| !git_worktree::fs::Capabilities::probe(std::env::temp_dir()).ignore_case);
28+
fn case_sensitive(tmp_dir: &std::path::Path) -> bool {
29+
std::fs::write(tmp_dir.join("config"), "").expect("can create file once");
30+
!git_worktree::fs::Capabilities::probe(tmp_dir).ignore_case
31+
}
3132

3233
#[test]
33-
#[ignore]
34-
fn conflicting_creation() -> crate::Result {
35-
let (_dir, store) = empty_store()?;
34+
fn conflicting_creation_without_packedrefs() -> crate::Result {
35+
let (dir, store) = empty_store()?;
3636
let res = store.transaction().prepare(
3737
[create_at("refs/a"), create_at("refs/A")],
3838
Fail::Immediately,
3939
Fail::Immediately,
4040
);
4141

42+
let case_sensitive = case_sensitive(dir.path());
4243
match res {
43-
Ok(_) if *CASE_SENSITIVE => {}
44-
Ok(_) if !*CASE_SENSITIVE => panic!("should fail as 'a' and 'A' clash"),
45-
Err(err) if *CASE_SENSITIVE => panic!(
44+
Ok(_) if case_sensitive => {}
45+
Ok(_) if !case_sensitive => panic!("should fail as 'a' and 'A' clash"),
46+
Err(err) if case_sensitive => panic!(
4647
"should work as case sensitivity allows 'a' and 'A' to coexist: {:?}",
4748
err
4849
),
49-
Err(err) if !*CASE_SENSITIVE => {
50-
assert_eq!(err.to_string(), "foo")
50+
Err(err) if !case_sensitive => {
51+
assert_eq!(err.to_string(), "A lock could not be obtained for reference \"refs/A\"")
5152
}
5253
_ => unreachable!("actually everything is covered"),
5354
}

0 commit comments

Comments
 (0)