mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-14 11:24:56 +02:00
Extract default relay host test
centralize common test variables and functions
This commit is contained in:
parent
6a7608fe7b
commit
db160bd977
5 changed files with 65 additions and 38 deletions
35
test/test_helper/common.bash
Normal file
35
test/test_helper/common.bash
Normal file
|
@ -0,0 +1,35 @@
|
|||
load 'test_helper/bats-support/load'
|
||||
load 'test_helper/bats-assert/load'
|
||||
|
||||
NAME=tvial/docker-mailserver:testing
|
||||
|
||||
# default timeout is 60 seconds
|
||||
TEST_TIMEOUT_IN_SECONDS=${TIMEOUT-60}
|
||||
|
||||
function repeat_until_success_or_timeout {
|
||||
if ![[ "$1" ~= '^[0-9]+$' ]]; then
|
||||
echo "First parameter for timeout must be an integer, recieved \"$1\""
|
||||
exit 1
|
||||
fi
|
||||
TIMEOUT=$1
|
||||
STARTTIME=$SECONDS
|
||||
shift 1
|
||||
until "$@"
|
||||
do
|
||||
sleep 5
|
||||
if [[ $(($SECONDS - $STARTTIME )) -gt $TIMEOUT ]]; then
|
||||
echo "Timed out on command: $@"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# @param $1 name of the postfix container
|
||||
function wait_for_smtp_port_in_container() {
|
||||
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS docker exec $1 /bin/sh -c "nc -z 0.0.0.0 25"
|
||||
}
|
||||
|
||||
# @param $1 name of the postfix container
|
||||
function wait_for_finished_setup_in_container() {
|
||||
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS sh -c "docker logs $1 | grep 'Starting mail server'"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue