Add more integration tests

This commit is contained in:
cytopia
2018-03-03 22:02:24 +01:00
parent fcbc2e5f84
commit 1730094042
8 changed files with 382 additions and 5 deletions

View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
IMAGE="${1}"
VERSION="${2}"
FLAVOUR="${3}"
# shellcheck disable=SC1090
. "${CWD}/../.lib.sh"
############################################################
# Tests
############################################################
###
### Postfix
###
MOUNTPOINT="$( mktemp --directory )"
did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e ENABLE_MAIL=1 -v ${MOUNTPOINT}:/var/mail" )"
run "sleep 10"
if ! run "docker logs ${did} 2>&1 | grep -q 'ENABLE_MAIL'"; then
docker_logs "${did}" || true
docker_stop "${did}" || true
echo "Failed"
exit 1
fi
if [ ! -f "${MOUNTPOINT}/devilbox" ]; then
echo "Mail file does not exist: ${MOUNTPOINT}/devilbox"
ls -lap ${MOUNTPOINT}/
docker_logs "${did}" || true
docker_stop "${did}" || true
echo "Failed"
exit 1
fi
if [ ! -r "${MOUNTPOINT}/devilbox" ]; then
echo "Mail file is not readable"
ls -lap ${MOUNTPOINT}/
docker_logs "${did}" || true
docker_stop "${did}" || true
echo "Failed"
exit 1
fi
# Send test email
docker_exec "${did}" "php -r \"mail('mailtest@devilbox.org', 'the subject', 'the message');\""
run "sleep 5"
if ! run "grep 'the subject' ${MOUNTPOINT}/devilbox"; then
docker_logs "${did}" || true
docker_stop "${did}" || true
echo "Failed"
"run cat ${MOUNTPOINT}/devilbox"
exit 1
fi
docker_stop "${did}"
run "rm -rf ${MOUNTPOINT}" || true