-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(infra): test the path resoltion error variants (#2210)
* test(infra): test the path resoltion error variants * test(infra): simplify resolve project relative path tests
- Loading branch information
1 parent
2547bb7
commit ab6c9b6
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::path::{path_of_project_root, resolve_project_relative_path, PathResolutionError}; | ||
|
||
// TODO: Add a test for PathResolutionError::IoError. | ||
#[test] | ||
fn resolve_project_relative_path_on_non_existent_path() { | ||
let relative_path = "does_not_exist.txt"; | ||
let expected_path = path_of_project_root().join(relative_path); | ||
assert!(!expected_path.exists()); | ||
let result = resolve_project_relative_path(relative_path); | ||
|
||
if let Err(PathResolutionError::PathDoesNotExist { path }) = result { | ||
assert_eq!(path, expected_path); | ||
} else { | ||
panic!("Expected PathDoesNotExist error, got {:?}", result); | ||
} | ||
} | ||
|
||
#[test] | ||
fn resolve_project_relative_path_success() { | ||
let relative_path = std::file!(); | ||
let result = resolve_project_relative_path(relative_path); | ||
|
||
assert!(result.unwrap().ends_with(relative_path)); | ||
} |