miti.sh/test.sh
Catalin Mititiuc 831a86c738 Don't publish any ports from the test container
This allows us to make test requests to port 80, like in production
2025-06-11 09:44:38 -07:00

41 lines
981 B
Bash
Executable File

#!/usr/bin/env bash
# echo "hello"
# curl http://webdevcat.me:8080
image=miti.sh
echo "Starting test container..."
container_id=$(docker run --rm -d -v $(pwd):/opt/app \
--add-host=miti.sh=127.0.0.1 \
--add-host=webdevcat.me=127.0.0.1 \
$image)
echo "Test container started"
docker exec -t $container_id busted
# echo "redirects webdevcat.me to miti.sh"
# response=$(docker exec -t $container_id curl -so /dev/null \
# -w "%{http_code} %{redirect_url}" http://webdevcat.me:8080)
# expected="301 http://miti.sh:8080/"
# if [[ $response != $expected ]]; then
# echo "TEST FAILED"
# printf "expected: $expected\ngot: $response\n"
# else
# echo "TEST PASSED"
# fi
echo "Stopping test container"
docker exec $container_id openresty -p /opt/app -s stop
is_running=$(docker inspect -f '{{.State.Running}}' $container_id)
if [[ $is_running == "true" ]]; then
echo "Warning: Docker reports test container is still running"
else
echo "Test container stopped"
fi