Skip to content

Commit d46f753

Browse files
committed
Use assert_error! in FilePath unit tests
1 parent dff0289 commit d46f753

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/file_path.test.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::assert_error;
12
use crate::file_path::FilePath;
23

34
#[test]
@@ -17,12 +18,9 @@ fn when_parsing_file_path_to_non_existing_file_then_return_no_such_file_error()
1718
"/nonexistent/../path/../file.log",
1819
];
1920
for path in paths {
20-
match FilePath::from(path) {
21-
Ok(_) => panic!("Error was expected"),
22-
Err(error) => assert_eq!(
23-
error.to_string(),
24-
"Error parsing directory path: No such file or directory (os error 2)"
25-
),
26-
};
21+
assert_error!(
22+
FilePath::from(path),
23+
"Error parsing directory path: No such file or directory (os error 2)"
24+
);
2725
}
2826
}

0 commit comments

Comments
 (0)