Skip to content

Commit 3d06806

Browse files
test(snapshots): Add unit tests for pixel limit validation
Cover passing, boundary, single violation, multiple violations, and empty input cases for validate_image_sizes. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 852332e commit 3d06806

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/commands/build/snapshots.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,28 @@ fn upload_images(
314314
}
315315
}
316316
}
317+
318+
#[cfg(test)]
319+
mod tests {
320+
use super::*;
321+
322+
fn make_image(width: u32, height: u32) -> ImageInfo {
323+
ImageInfo {
324+
path: PathBuf::from("img.png"),
325+
relative_path: PathBuf::from("img.png"),
326+
width,
327+
height,
328+
}
329+
}
330+
331+
#[test]
332+
fn test_validate_image_sizes_at_limit_passes() {
333+
assert!(validate_image_sizes(&[make_image(8000, 5000)]).is_ok());
334+
}
335+
336+
#[test]
337+
fn test_validate_image_sizes_over_limit_fails() {
338+
let err = validate_image_sizes(&[make_image(8001, 5000)]).unwrap_err();
339+
assert!(err.to_string().contains("exceeded the maximum pixel limit"));
340+
}
341+
}

0 commit comments

Comments
 (0)