Skip to content

Commit 9d49f98

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

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/opts.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,35 @@ 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+
dbg!(&original);
112+
assert_eq!(original, Ok(path.into()));
113+
114+
// Set
115+
set_search_path(ConfigLevel::Global, &path)?;
116+
assert_eq!(get_search_path(ConfigLevel::Global), Ok(path.into()));
117+
118+
// Append
119+
let paths = join_paths(["$PATH", path].iter())?;
120+
let expected_paths = join_paths([path, path].iter())?.into_string().unwrap();
121+
set_search_path(ConfigLevel::Global, paths)?;
122+
assert_eq!(get_search_path(ConfigLevel::Global), Ok(expected_paths));
123+
124+
// Reset
125+
reset_search_path(ConfigLevel::Global)?;
126+
assert_eq!(get_search_path(ConfigLevel::Global), original);
127+
128+
Ok(())
102129
}
103130
}

0 commit comments

Comments
 (0)