Skip to content

Commit

Permalink
Fix unit-tests for new api
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Regali committed Jul 25, 2023
1 parent 83c32c6 commit d324407
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ mod test {
let result = compare_files(actual, nominal, &HTMLCompareConfig::default()).unwrap();

assert!(result.is_error);

assert!(result.detail_path.is_some());
}

#[test]
Expand Down
30 changes: 15 additions & 15 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub fn compare_paths<P: AsRef<Path>>(
#[cfg(test)]
mod test {
use crate::image::{compare_paths, ImageCompareConfig};
use crate::report::DiffDetail;

#[test]
fn identity() {
Expand All @@ -99,21 +100,20 @@ mod test {
)
.unwrap();
assert!(result.is_error);
assert!(result.detail_path.is_some());
let img = image::open(
result
.detail_path
if let DiffDetail::Image {
score: _,
diff_image,
} = result.detail.first().unwrap()
{
let img = image::open(diff_image).unwrap().into_rgb8();
let nom = image::open("tests/integ/data/images/diff_100_DPI.png")
.unwrap()
.temp_path
.join("SaveImage_100DPI_default_size.jpgdiff_image.png"),
)
.expect("Could not load generated diff image")
.into_rgb8();
let nom = image::open("tests/integ/data/images/diff_100_DPI.png")
.unwrap()
.into_rgb8();
let diff_result = image_compare::rgb_hybrid_compare(&img, &nom)
.expect("Wrong dimensions of diff images!");
assert_eq!(diff_result.score, 1.0);
.into_rgb8();
let diff_result = image_compare::rgb_hybrid_compare(&img, &nom)
.expect("Wrong dimensions of diff images!");
assert_eq!(diff_result.score, 1.0);
} else {
unreachable!();
}
}
}
5 changes: 3 additions & 2 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ mod tests {
let regex_no_spaces = r"[\s]";
assert!(
regex_matches_any_path(file_name_mock, file_name_cap_mock, regex_no_capitals)
.unwrap()
.unwrap()
.is_error
);
assert!(
!regex_matches_any_path(file_name_mock, file_name_cap_mock, regex_no_spaces)
regex_matches_any_path(file_name_mock, file_name_cap_mock, regex_no_spaces)
.unwrap()
.is_error
.is_none()
);
}

Expand Down

0 comments on commit d324407

Please sign in to comment.