Files
image-gateway/scripts/test-e2e.sh

47 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
set -euo pipefail
project_name="${COMPOSE_PROJECT_NAME:-image-gateway-test-${CI_JOB_ID:-${GITHUB_RUN_ID:-local}}}"
compose=(docker compose -p "${project_name}" -f docker-compose.test.yml)
cleanup() {
status=$?
if [ "${status}" -ne 0 ]; then
"${compose[@]}" logs --no-color || true
fi
"${compose[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
exit "${status}"
}
trap cleanup EXIT
"${compose[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
"${compose[@]}" up -d --build caddy imgproxy fixture
"${compose[@]}" run --rm tester bun test tests/e2e/cache-prime.test.js
"${compose[@]}" restart caddy
"${compose[@]}" run --rm tester bun test tests/e2e/cache-persistence.test.js
"${compose[@]}" run --rm tester bun test tests/e2e/cache-purge.test.js
logs=$("${compose[@]}" logs --no-color caddy)
case "${logs}" in
*"default storage that is not optimized"*)
printf '%s\n' "Caddy logs contain Souin default storage warning"
exit 1
;;
esac
case "${logs}" in
*"NUTS-INSERTION-ERROR"*)
printf '%s\n' "Caddy logs contain NUTS-INSERTION-ERROR"
exit 1
;;
esac
printf '%s\n' "E2E cache tests passed"