miti.sh/test.sh
Catalin Constantin Mititiuc 406208f26c Add tests for nginx.conf directives (#1)
Adds tests to make sure all the `nginx.conf` directives (the redirects and rewrites and such) are all correct.

- Uses the `busted` framework
- The tests are run in a Docker container by the bash script `test.sh`
- Self-signed certs are generated in `Dockerfile` for all the domain names
- Adds new `Makefile` commands: `test`, `image-build` and `image-rm`

Reviewed-on: #1
Co-authored-by: Catalin Mititiuc <webdevcat@proton.me>
Co-committed-by: Catalin Mititiuc <webdevcat@proton.me>
2025-06-16 20:18:05 -07:00

26 lines
764 B
Bash
Executable File

#!/usr/bin/env bash
image=miti.sh
loopback=127.0.0.1
# Make sure to create 'no-internet' network, if it doesn't already exist:
# $ docker network create --internal no-internet
container_id=$(docker run --rm -d -v $(pwd):/opt/app --network no-internet \
--add-host=miti.sh=$loopback \
--add-host=git.miti.sh=$loopback \
--add-host=apps.miti.sh=$loopback \
--add-host=webdevcat.me=$loopback \
--add-host=git.webdevcat.me=$loopback \
--add-host=apps.webdevcat.me=$loopback \
$image)
docker exec -t $container_id busted
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"
fi