Skip to content

Commit b741fbd

Browse files
committed
test(opts): get/set/reset search path
1 parent 980bf38 commit b741fbd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/opts.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,34 @@ pub fn strict_hash_verification(enabled: bool) {
9696

9797
#[cfg(test)]
9898
mod test {
99+
use super::*;
100+
use std::env::join_paths;
101+
99102
#[test]
100103
fn smoke() {
101-
super::strict_hash_verification(false);
104+
strict_hash_verification(false);
105+
}
106+
107+
#[test]
108+
fn search_path() -> Result<(), Box<dyn std::error::Error>> {
109+
let path = "fake_path";
110+
let original = get_search_path(ConfigLevel::Global);
111+
assert_ne!(original, Ok(path.into()));
112+
113+
// Set
114+
set_search_path(ConfigLevel::Global, &path)?;
115+
assert_eq!(get_search_path(ConfigLevel::Global), Ok(path.into()));
116+
117+
// Append
118+
let paths = join_paths(["$PATH", path].iter())?;
119+
let expected_paths = join_paths([path, path].iter())?.into_string().unwrap();
120+
set_search_path(ConfigLevel::Global, paths)?;
121+
assert_eq!(get_search_path(ConfigLevel::Global), Ok(expected_paths));
122+
123+
// Reset
124+
reset_search_path(ConfigLevel::Global)?;
125+
assert_eq!(get_search_path(ConfigLevel::Global), original);
126+
127+
Ok(())
102128
}
103129
}

0 commit comments

Comments
 (0)