From 34dfbb17162c40fb449be9ac7e381069da17ee20 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Fri, 22 Mar 2024 20:48:27 +0800 Subject: [PATCH] Fix tests from changes in libgit2 v1.8 --- src/cred.rs | 2 +- tests/add_extensions.rs | 6 ++++-- tests/get_extensions.rs | 4 +++- tests/remove_extensions.rs | 9 ++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cred.rs b/src/cred.rs index fc4af1e4eb..fc0b941935 100644 --- a/src/cred.rs +++ b/src/cred.rs @@ -482,7 +482,7 @@ mod test { macro_rules! test_cfg( ($($k:expr => $v:expr),*) => ({ let td = TempDir::new().unwrap(); let mut cfg = Config::new().unwrap(); - cfg.add_file(&td.path().join("cfg"), ConfigLevel::Highest, false).unwrap(); + cfg.add_file(&td.path().join("cfg"), ConfigLevel::App, false).unwrap(); $(cfg.set_str($k, $v).unwrap();)* cfg }) ); diff --git a/tests/add_extensions.rs b/tests/add_extensions.rs index 57c0eb9762..dec1ac92e0 100644 --- a/tests/add_extensions.rs +++ b/tests/add_extensions.rs @@ -11,11 +11,13 @@ fn test_add_extensions() -> Result<(), Error> { let extensions = unsafe { get_extensions() }?; - assert_eq!(extensions.len(), 3); + assert_eq!(extensions.len(), 4); assert_eq!(extensions.get(0), Some("custom")); - // The objectformat extension was added in 1.6 assert_eq!(extensions.get(1), Some("noop")); + // The objectformat extension was added in 1.6 assert_eq!(extensions.get(2), Some("objectformat")); + // The objectformat extension was added in 1.8 + assert_eq!(extensions.get(3), Some("worktreeconfig")); Ok(()) } diff --git a/tests/get_extensions.rs b/tests/get_extensions.rs index d8dd55fe0a..283c978d1b 100644 --- a/tests/get_extensions.rs +++ b/tests/get_extensions.rs @@ -7,10 +7,12 @@ use git2::Error; fn test_get_extensions() -> Result<(), Error> { let extensions = unsafe { get_extensions() }?; - assert_eq!(extensions.len(), 2); + assert_eq!(extensions.len(), 3); assert_eq!(extensions.get(0), Some("noop")); // The objectformat extension was added in 1.6 assert_eq!(extensions.get(1), Some("objectformat")); + // The objectformat extension was added in 1.8 + assert_eq!(extensions.get(2), Some("worktreeconfig")); Ok(()) } diff --git a/tests/remove_extensions.rs b/tests/remove_extensions.rs index 5f632a8809..5384daea5c 100644 --- a/tests/remove_extensions.rs +++ b/tests/remove_extensions.rs @@ -6,7 +6,14 @@ use git2::Error; #[test] fn test_remove_extensions() -> Result<(), Error> { unsafe { - set_extensions(&["custom", "!ignore", "!noop", "!objectformat", "other"])?; + set_extensions(&[ + "custom", + "!ignore", + "!noop", + "!objectformat", + "!worktreeconfig", + "other", + ])?; } let extensions = unsafe { get_extensions() }?;