mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 09:34:33 +02:00
tests: refactor 4 more tests (#3018)
This commit is contained in:
parent
d7dee5d8a4
commit
0fd7c362da
7 changed files with 117 additions and 125 deletions
|
@ -60,7 +60,7 @@ function __handle_container_name() {
|
|||
printf '%s' "${CONTAINER_NAME}"
|
||||
return 0
|
||||
else
|
||||
echo 'ERROR: (helper/common.sh) Container name was either provided explicitly without the required `dms-test_` prefix, or CONTAINER_NAME is not set for implicit usage' >&2
|
||||
echo 'ERROR: (helper/common.sh) Container name was either provided explicitly without the required "dms-test_" prefix, or CONTAINER_NAME is not set for implicit usage' >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
@ -119,6 +119,27 @@ function _exec_in_container_bash() { _exec_in_container /bin/bash -c "${@}" ; }
|
|||
# @param ... = Bash command to execute
|
||||
function _run_in_container_bash() { _run_in_container /bin/bash -c "${@}" ; }
|
||||
|
||||
# Run a command in Bash and filter the output given a regex.
|
||||
#
|
||||
# @param ${1} = command to run in Bash
|
||||
# @param ${2} = regex to filter [OPTIONAL]
|
||||
#
|
||||
# ## Attention
|
||||
#
|
||||
# The regex is given to `grep -E`, so make sure it is compatible.
|
||||
#
|
||||
# ## Note
|
||||
#
|
||||
# If no regex is provided, this function will default to one that strips
|
||||
# empty lines and Bash comments from the output.
|
||||
function _run_in_container_bash_and_filter_output() {
|
||||
local COMMAND=${1:?Command must be provided}
|
||||
local FILTER_REGEX=${2:-^[[:space:]]*$|^ *#}
|
||||
|
||||
_run_in_container_bash "${COMMAND} | grep -E -v '${FILTER_REGEX}'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# ? << Functions to execute commands inside a container
|
||||
# ! -------------------------------------------------------------------
|
||||
# ? >> Functions about executing commands with timeouts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue