diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
commit | 2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch) | |
tree | 033cc839730fda84ff08db877037977be94e5e3a /vendor/git2/tests | |
parent | Initial commit. (diff) | |
download | cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip |
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/git2/tests')
-rw-r--r-- | vendor/git2/tests/add_extensions.rs | 21 | ||||
-rw-r--r-- | vendor/git2/tests/get_extensions.rs | 16 | ||||
-rw-r--r-- | vendor/git2/tests/global_state.rs | 47 | ||||
-rw-r--r-- | vendor/git2/tests/remove_extensions.rs | 19 |
4 files changed, 103 insertions, 0 deletions
diff --git a/vendor/git2/tests/add_extensions.rs b/vendor/git2/tests/add_extensions.rs new file mode 100644 index 0000000..57c0eb9 --- /dev/null +++ b/vendor/git2/tests/add_extensions.rs @@ -0,0 +1,21 @@ +//! Test for `set_extensions`, which writes a global state maintained by libgit2 + +use git2::opts::{get_extensions, set_extensions}; +use git2::Error; + +#[test] +fn test_add_extensions() -> Result<(), Error> { + unsafe { + set_extensions(&["custom"])?; + } + + let extensions = unsafe { get_extensions() }?; + + assert_eq!(extensions.len(), 3); + assert_eq!(extensions.get(0), Some("custom")); + // The objectformat extension was added in 1.6 + assert_eq!(extensions.get(1), Some("noop")); + assert_eq!(extensions.get(2), Some("objectformat")); + + Ok(()) +} diff --git a/vendor/git2/tests/get_extensions.rs b/vendor/git2/tests/get_extensions.rs new file mode 100644 index 0000000..d8dd55f --- /dev/null +++ b/vendor/git2/tests/get_extensions.rs @@ -0,0 +1,16 @@ +//! Test for `get_extensions`, which reads a global state maintained by libgit2 + +use git2::opts::get_extensions; +use git2::Error; + +#[test] +fn test_get_extensions() -> Result<(), Error> { + let extensions = unsafe { get_extensions() }?; + + assert_eq!(extensions.len(), 2); + assert_eq!(extensions.get(0), Some("noop")); + // The objectformat extension was added in 1.6 + assert_eq!(extensions.get(1), Some("objectformat")); + + Ok(()) +} diff --git a/vendor/git2/tests/global_state.rs b/vendor/git2/tests/global_state.rs new file mode 100644 index 0000000..192acdb --- /dev/null +++ b/vendor/git2/tests/global_state.rs @@ -0,0 +1,47 @@ +//! Test for some global state set up by libgit2's `git_libgit2_init` function +//! that need to be synchronized within a single process. + +use git2::opts; +use git2::{ConfigLevel, IntoCString}; + +// Test for mutating configuration file search path which is set during +// initialization in libgit2's `git_sysdir_global_init` function. +#[test] +fn search_path() -> Result<(), Box<dyn std::error::Error>> { + use std::env::join_paths; + + let path = "fake_path"; + let original = unsafe { opts::get_search_path(ConfigLevel::Global) }; + assert_ne!(original, Ok(path.into_c_string()?)); + + // Set + unsafe { + opts::set_search_path(ConfigLevel::Global, &path)?; + } + assert_eq!( + unsafe { opts::get_search_path(ConfigLevel::Global) }, + Ok(path.into_c_string()?) + ); + + // Append + let paths = join_paths(["$PATH", path].iter())?; + let expected_paths = join_paths([path, path].iter())?.into_c_string()?; + unsafe { + opts::set_search_path(ConfigLevel::Global, paths)?; + } + assert_eq!( + unsafe { opts::get_search_path(ConfigLevel::Global) }, + Ok(expected_paths) + ); + + // Reset + unsafe { + opts::reset_search_path(ConfigLevel::Global)?; + } + assert_eq!( + unsafe { opts::get_search_path(ConfigLevel::Global) }, + original + ); + + Ok(()) +} diff --git a/vendor/git2/tests/remove_extensions.rs b/vendor/git2/tests/remove_extensions.rs new file mode 100644 index 0000000..5f632a8 --- /dev/null +++ b/vendor/git2/tests/remove_extensions.rs @@ -0,0 +1,19 @@ +//! Test for `set_extensions`, which writes a global state maintained by libgit2 + +use git2::opts::{get_extensions, set_extensions}; +use git2::Error; + +#[test] +fn test_remove_extensions() -> Result<(), Error> { + unsafe { + set_extensions(&["custom", "!ignore", "!noop", "!objectformat", "other"])?; + } + + let extensions = unsafe { get_extensions() }?; + + assert_eq!(extensions.len(), 2); + assert_eq!(extensions.get(0), Some("custom")); + assert_eq!(extensions.get(1), Some("other")); + + Ok(()) +} |