Add bats test suite for image processing scripts

Tests cover skip-already-processed logic, cleanup, idempotency, and
the config.sh single-source-of-truth invariant. bats-core, bats-assert,
and bats-support added as submodules under tests/libs/.
This commit is contained in:
2026-07-03 19:49:04 -04:00
parent 6901c66bcf
commit f5ed6617c5
11 changed files with 233 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bats
load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'helpers/common'
@test "config.sh defines MAGICK_COMMENT" {
run bash -c "source '$REPO_ROOT/config.sh' && echo \"\$MAGICK_COMMENT\""
assert_success
assert_output "magick:resize=8mp,quality=85,sampling=4:2:0"
}
@test "config.sh defines MAX_PIXELS" {
run bash -c "source '$REPO_ROOT/config.sh' && echo \"\$MAX_PIXELS\""
assert_success
assert_output "8000000"
}
@test "MAGICK_COMMENT matches in images_resize.sh and zip_images_resize.sh" {
local comment_from_config comment_in_resize comment_in_zip
comment_from_config=$(bash -c "source '$REPO_ROOT/config.sh' && echo \"\$MAGICK_COMMENT\"")
comment_in_resize=$(grep 'MAGICK_COMMENT=' "$REPO_ROOT/images_resize.sh" | grep -v source || true)
comment_in_zip=$(grep 'MAGICK_COMMENT=' "$REPO_ROOT/zip_images_resize.sh" | grep -v source || true)
# Neither script should define MAGICK_COMMENT itself — only config.sh should
assert_equal "" "$comment_in_resize"
assert_equal "" "$comment_in_zip"
}