2023-01-12 21:13:42 +00:00
|
|
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
2023-01-21 23:05:28 +00:00
|
|
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
2021-09-06 10:13:12 +00:00
|
|
|
|
2023-01-30 08:19:47 +00:00
|
|
|
# ! ATTENTION: Must be run in serial mode, as no existing containers should be present.
|
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
# Tests the `setup.sh` companion script.
|
|
|
|
# Only test coverage below is that the config path `-p` and image `-i` options work as intended.
|
|
|
|
BATS_TEST_NAME_PREFIX='[No Existing Container] '
|
2022-08-22 23:24:23 +00:00
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
function setup_file() {
|
2023-02-06 22:59:01 +00:00
|
|
|
run docker ps # fail early if the testing image is already running:
|
|
|
|
assert_success
|
|
|
|
refute_output --partial "${IMAGE_NAME}"
|
2021-09-06 10:13:12 +00:00
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
export TEST_TMP_CONFIG
|
2023-01-21 23:05:28 +00:00
|
|
|
TEST_TMP_CONFIG=$(_duplicate_config_for_container . 'no_container')
|
2021-09-06 10:13:12 +00:00
|
|
|
}
|
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
@test "'setup.sh -p <PATH> -i <IMAGE>' should correctly use options" {
|
|
|
|
# Create a `postfix-virtual.cf` config to verify the container can access it:
|
|
|
|
local MAIL_ALIAS='no_container@example.test no_container@forward.test'
|
|
|
|
echo "${MAIL_ALIAS}" > "${TEST_TMP_CONFIG}/postfix-virtual.cf"
|
2021-09-06 10:13:12 +00:00
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
# Should run the testing image with a volume mount to the provided path:
|
|
|
|
run ./setup.sh -p "${TEST_TMP_CONFIG}" -i "${IMAGE_NAME}" alias list
|
2021-09-06 10:13:12 +00:00
|
|
|
assert_success
|
2023-01-12 21:13:42 +00:00
|
|
|
assert_output --partial "* ${MAIL_ALIAS}"
|
2022-08-22 23:24:23 +00:00
|
|
|
}
|