change if style (#3361)

This commit is contained in:
Casper 2023-05-24 09:06:59 +02:00 committed by GitHub
parent 0e592aa911
commit cf74127f78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 297 additions and 594 deletions

View file

@ -52,12 +52,10 @@ __load_bats_helper
#
# This function is internal and should not be used in tests.
function __handle_container_name() {
if [[ -n ${1:-} ]] && [[ ${1:-} =~ ^dms-test_ ]]
then
if [[ -n ${1:-} ]] && [[ ${1:-} =~ ^dms-test_ ]]; then
printf '%s' "${1}"
return 0
elif [[ -n ${CONTAINER_NAME+set} ]]
then
elif [[ -n ${CONTAINER_NAME+set} ]]; then
printf '%s' "${CONTAINER_NAME}"
return 0
else
@ -169,8 +167,7 @@ function _repeat_in_container_until_success_or_timeout() {
function _repeat_until_success_or_timeout() {
local FATAL_FAILURE_TEST_COMMAND
if [[ "${1:-}" == "--fatal-test" ]]
then
if [[ "${1:-}" == "--fatal-test" ]]; then
FATAL_FAILURE_TEST_COMMAND="${2:?Provided --fatal-test but no command}"
shift 2
fi
@ -178,8 +175,7 @@ function _repeat_until_success_or_timeout() {
local TIMEOUT=${1:?Timeout duration must be provided}
shift 1
if ! [[ "${TIMEOUT}" =~ ^[0-9]+$ ]]
then
if ! [[ "${TIMEOUT}" =~ ^[0-9]+$ ]]; then
echo "First parameter for timeout must be an integer, received \"${TIMEOUT}\""
return 1
fi
@ -188,16 +184,14 @@ function _repeat_until_success_or_timeout() {
until "${@}"
do
if [[ -n ${FATAL_FAILURE_TEST_COMMAND} ]] && ! eval "${FATAL_FAILURE_TEST_COMMAND}"
then
if [[ -n ${FATAL_FAILURE_TEST_COMMAND} ]] && ! eval "${FATAL_FAILURE_TEST_COMMAND}"; then
echo "\`${FATAL_FAILURE_TEST_COMMAND}\` failed, early aborting repeat_until_success of \`${*}\`" >&2
return 1
fi
sleep 1
if [[ $(( SECONDS - STARTTIME )) -gt ${TIMEOUT} ]]
then
if [[ $(( SECONDS - STARTTIME )) -gt ${TIMEOUT} ]]; then
echo "Timed out on command: ${*}" >&2
return 1
fi
@ -213,8 +207,7 @@ function _run_until_success_or_timeout() {
local TIMEOUT=${1:?Timeout duration must be provided}
shift 1
if [[ ! ${TIMEOUT} =~ ^[0-9]+$ ]]
then
if [[ ! ${TIMEOUT} =~ ^[0-9]+$ ]]; then
echo "First parameter for timeout must be an integer, received \"${TIMEOUT}\""
return 1
fi
@ -226,8 +219,7 @@ function _run_until_success_or_timeout() {
do
sleep 1
if (( SECONDS - STARTTIME > TIMEOUT ))
then
if (( SECONDS - STARTTIME > TIMEOUT )); then
echo "Timed out on command: ${*}" >&2
return 1
fi
@ -270,8 +262,7 @@ function _wait_for_smtp_port_in_container_to_respond() {
local COUNT=0
until [[ $(_exec_in_container timeout 10 /bin/bash -c 'echo QUIT | nc localhost 25') == *'221 2.0.0 Bye'* ]]
do
if [[ ${COUNT} -eq 20 ]]
then
if [[ ${COUNT} -eq 20 ]]; then
echo "Unable to receive a valid response from 'nc localhost 25' within 20 seconds"
return 1
fi