Co-authored-by: Marco Tolk <marco@marcotolk.com>
This commit is contained in:
Marco Tolk 2021-03-11 19:47:42 +01:00 committed by GitHub
parent 25ef603990
commit 5964fc192c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

1
Cargo.lock generated
View file

@ -3302,6 +3302,7 @@ dependencies = [
"open",
"percent-encoding",
"relative-path",
"same-file",
"serde_json",
"site",
"termcolor",

View file

@ -45,6 +45,9 @@ errors = { path = "components/errors" }
front_matter = { path = "components/front_matter" }
utils = { path = "components/utils" }
[dev-dependencies]
same-file = "1"
[workspace]
members = [
"components/config",

View file

@ -250,16 +250,15 @@ mod tests {
#[test]
fn strip_unc_test() {
let mut dir = temp_dir();
dir.push("new_project");
dir.push("new_project1");
if dir.exists() {
remove_dir_all(&dir).expect("Could not free test directory");
}
create_dir(&dir).expect("Could not create test directory");
if cfg!(target_os = "windows") {
assert_eq!(
strip_unc(&canonicalize(Path::new(&dir)).unwrap()),
"C:\\Users\\VssAdministrator\\AppData\\Local\\Temp\\new_project"
)
let stripped_path = strip_unc(&canonicalize(Path::new(&dir)).unwrap());
assert!(same_file::is_same_file(Path::new(&stripped_path),&dir).unwrap());
assert!(!stripped_path.starts_with(LOCAL_UNC),"The path was not stripped.");
} else {
assert_eq!(
strip_unc(&canonicalize(Path::new(&dir)).unwrap()),
@ -277,15 +276,15 @@ mod tests {
#[cfg(target_os = "windows")]
fn strip_unc_required_test() {
let mut dir = temp_dir();
dir.push("new_project");
dir.push("new_project2");
if dir.exists() {
remove_dir_all(&dir).expect("Could not free test directory");
}
create_dir(&dir).expect("Could not create test directory");
assert_eq!(
canonicalize(Path::new(&dir)).unwrap().to_str().unwrap(),
"\\\\?\\C:\\Users\\VssAdministrator\\AppData\\Local\\Temp\\new_project"
);
let canonicalized_path = canonicalize(Path::new(&dir)).unwrap();
assert!(same_file::is_same_file(Path::new(&canonicalized_path),&dir).unwrap());
assert!(canonicalized_path.to_str().unwrap().starts_with(LOCAL_UNC));
remove_dir_all(&dir).unwrap();
}