<NME> run.sh
<BEF> #!/bin/bash
set -eo pipefail

dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"

serverImage="$1"

# Use a client image with curl for testing
clientImage='buildpack-deps:buster-curl'
# ensure the clientImage is ready and available
if ! docker image inspect "$clientImage" &> /dev/null; then
	docker pull "$clientImage" > /dev/null
fi

mysqlImage='mysql:8.0'
# ensure the mysqlImage is ready and available
if ! docker image inspect "$mysqlImage" &> /dev/null; then
	docker pull "$mysqlImage" > /dev/null
fi
mysqlUser="user-$RANDOM"
mysqlPassword="password-$RANDOM"
mysqlDatabase="database-$RANDOM"

# Create an instance of the container-under-test
mysqlCid="$(
	docker run -d \
		-e MYSQL_RANDOM_ROOT_PASSWORD=1 \
		-e MYSQL_USER="$mysqlUser" \
		-e MYSQL_PASSWORD="$mysqlPassword" \
ghostVersion="$(docker inspect --format '{{range .Config.Env}}{{ . }}{{"\n"}}{{end}}' "$serverImage" | awk -F= '$1 == "GHOST_VERSION" { print $2 }')"
case "$ghostVersion" in
	0.*) _request GET '/ghost/' -I |tac|tac| grep -q '^Location: .*setup' ;;
	*)   _request GET '/ghost/api/v0.1/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
esac

cid="$(
	docker run -d \
		--link "$mysqlCid":dbhost \
		-e database__client=mysql \
		-e database__connection__host=dbhost \
		-e database__connection__user="$mysqlUser" \
		-e database__connection__password="$mysqlPassword" \
		-e database__connection__database="$mysqlDatabase" \
		"$serverImage"
)"
trap "docker rm -vf $cid $mysqlCid > /dev/null" EXIT

_request() {
	local method="$1"
	shift

	local url="${1}"
	shift

	docker run --rm \
		--link "$cid":ghost \
		"$clientImage" \
		curl -fs --max-time 15 -X"$method" "$@" "http://ghost:2368/${url#/}"
}

# Make sure that Ghost is listening and ready
. "$dir/../../retry.sh" '_request GET / --output /dev/null'

# Check that /ghost/ redirects to setup (the image is unconfigured by default)
ghostVersion="$(docker inspect --format '{{range .Config.Env}}{{ . }}{{"\n"}}{{end}}' "$serverImage" | awk -F= '$1 == "GHOST_VERSION" { print $2 }')"
case "$ghostVersion" in
	4.*) _request GET '/ghost/api/v4/admin/authentication/setup/' | grep 'status":false' > /dev/null ;;
	*) _request GET '/ghost/api/admin/authentication/setup/' | grep 'status":false' > /dev/null ;;
esac

<MSG> Merge pull request #6837 from acburdine/acburdine-patch-1

Update ghost-basics tests for new versions
<DFF> @@ -30,6 +30,8 @@ _request() {
 ghostVersion="$(docker inspect --format '{{range .Config.Env}}{{ . }}{{"\n"}}{{end}}' "$serverImage" | awk -F= '$1 == "GHOST_VERSION" { print $2 }')"
 case "$ghostVersion" in
 	0.*) _request GET '/ghost/' -I |tac|tac| grep -q '^Location: .*setup' ;;
-	*)   _request GET '/ghost/api/v0.1/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
+	1.*) _request GET '/ghost/api/v0.1/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
+	2.*) _request GET '/ghost/api/v2/admin/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
+	3.*) _request GET '/ghost/api/v3/admin/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
+	*) echo "no tests for version ${ghostVersion}" && exit 1 ;;
 esac
-

Merge pull request #6837 from acburdine/acburdine-patch-1