docker-mailserver/test/tests/parallel/set2/template.bats
Brennan Kinney 75ee0c1145 tests(refactor): Conversion to parallel tests and use revised helpers
- Introduced `CONTAINER_NAME` and `TEST_NAME_PREFIX` as new vars for better managing test consistency (DRY).
- `CONTAINER_NAME` replaces any repeated container name with the variable. The value will differ slightly as the prior prefix (`mail_`) has been changed to `dms-test-`.
- `TEST_NAME_PREFIX` provides a prefix value for each `@test` description string.

---

chore: Add a reference template for tests
2022-11-26 14:52:42 +13:00

40 lines
889 B
Bash

# ? load the BATS helper
load "${REPOSITORY_ROOT}/test/helper/setup"
load "${REPOSITORY_ROOT}/test/helper/common"
# ? global variable initialization
# ? to identify the test easily
TEST_NAME_PREFIX='template:'
# ? must be unique
CONTAINER_NAME='dms-test-template'
# ? test setup
function setup_file() {
# ? optional setup before container is started
# ? initialize the test helpers
init_with_defaults
# ? add custom arguments supplied to `docker run` here
local CUSTOM_SETUP_ARGUMENTS=(
--env LOG_LEVEL=trace
)
# ? use a helper to correctly setup the container
common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
# ? optional setup after the container is started
}
# ? test finalization
function teardown_file() { _default_teardown ; }
# ? actual unit tests
@test "${TEST_NAME_PREFIX} default check" {
_run_in_container bash -c "true"
assert_success
}