Ok, let's say I wanna test this script, without installing docker-compose:
$ cat manage.sh
#!/bin/sh
RUNNING_IDS=$(docker-compose ps -q)
if [ -z "$RUNNING_IDS" ]; then
echo "docker-compose is not running."
exit 1
fi
docker-compose exec -e LOG_LEVEL=${LOG_LEVEL:-INFO} backend python3 manage.py "$@"
I can use the PATH trick:
$ printf '#!/bin/sh' > docker-compose && chmod +x docker-compose && PATH=.:$PATH ./manage.sh
docker-compose is not running.
Here I create a docker-compose file (that is just an empty shell script), and called the script that I wanted to test with the current directory added to the PATH.
Sick when im off work ill test this. Thanks. Kinda new to shell scripting and making one that "holds the users hand" has been a fun challenge.
Thread collapsed