miti.sh/test.sh

44 lines
1.1 KiB
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 -p 8080:8080 \
--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 curl http://miti.sh:8080
# docker exec -t $container_id curl -v http://webdevcat.me:8080
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