mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2024-04-28 08:45:06 +02:00
1650cdf76f
* chore: Remove `backup` target from Makefile - The `backup` target is no longer serving any value to us. It was made redundant with changes added in Oct 2020. - `clean` target inline docs revised. - `.gitignore` remove test lines that are no longer valid. * chore: Parallel test target split to multi-line * tests(fix): Test `setup.sh` with temporary config dir The `no_containers.bats` test has many redundant test cases already covered by `setup-cli`. They're basically identical. Removed all but one. This removes some config dirs that were being explicitly created instead of using the test helper to generate a directory that can be used to test the `-p` option instead. * ci: Ensure tests are run when `Makefile` is modified
28 lines
1.2 KiB
Bash
28 lines
1.2 KiB
Bash
load "${REPOSITORY_ROOT}/test/helper/common"
|
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
|
|
|
# Tests the `setup.sh` companion script.
|
|
# Only test coverage below is that the config path `-p` and image `-i` options work as intended.
|
|
# NOTE: Must be run in serial mode, as no existing containers should be present.
|
|
BATS_TEST_NAME_PREFIX='[No Existing Container] '
|
|
|
|
function setup_file() {
|
|
# Fail early if the testing image is already running:
|
|
assert_not_equal "$(docker ps | grep -o "${IMAGE_NAME}")" "${IMAGE_NAME}"
|
|
|
|
# Copy the base config that `setup.sh` will volume mount to a container it runs:
|
|
export TEST_TMP_CONFIG
|
|
TEST_TMP_CONFIG=$(duplicate_config_for_container . 'no_container')
|
|
}
|
|
|
|
@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"
|
|
|
|
# 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
|
|
assert_success
|
|
assert_output --partial "* ${MAIL_ALIAS}"
|
|
}
|