tests(chore): Use REPOSITORY_ROOT export var from Makefile

Allows for using `load` with an absolute path instead of a relative one, which makes it possible to group tests into different directories.

Parallel tests differ slightly, loading the newer `helper/common.bash` and `helper/setup.bash` files instead of the older `test_helper/common.bash` which serial tests continue to use.
This commit is contained in:
Brennan Kinney 2022-11-26 11:37:58 +13:00
parent 2cd534a1ab
commit 835056d707
43 changed files with 50 additions and 49 deletions

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
load 'test_helper/bats-support/load' load "${REPOSITORY_ROOT}/test/test_helper/bats-support/load"
load 'test_helper/bats-assert/load' load "${REPOSITORY_ROOT}/test/test_helper/bats-assert/load"
NAME=${NAME:-mailserver-testing:ci} NAME=${NAME:-mailserver-testing:ci}

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Helper methods for testing TLS. # Helper methods for testing TLS.
# `_should_*` methods are useful for common high-level functionality. # `_should_*` methods are useful for common high-level functionality.

View file

@ -1,4 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/helper/setup"
load "${REPOSITORY_ROOT}/test/helper/common"
TEST_NAME_PREFIX='ClamAV:' TEST_NAME_PREFIX='ClamAV:'
CONTAINER_NAME='dms-test-clamav' CONTAINER_NAME='dms-test-clamav'

View file

@ -1,4 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/helper/setup"
load "${REPOSITORY_ROOT}/test/helper/common"
function setup() { function setup() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,6 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/helper/setup"
# Globals referenced from `test_helper/common`: load "${REPOSITORY_ROOT}/test/helper/common"
# TEST_NAME
# Can run tests in parallel?: No # Can run tests in parallel?: No
# Shared static container name: TEST_NAME # Shared static container name: TEST_NAME

View file

@ -1,4 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/helper/setup"
load "${REPOSITORY_ROOT}/test/helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/helper/setup"
load "${REPOSITORY_ROOT}/test/helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Note if tests fail asserting against `supervisorctl tail changedetector` output, # Note if tests fail asserting against `supervisorctl tail changedetector` output,
# use `supervisorctl tail -<num bytes> changedetector` instead to increase log output. # use `supervisorctl tail -<num bytes> changedetector` instead to increase log output.

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
CONTAINER="mail_dnsbl_enabled" CONTAINER="mail_dnsbl_enabled"
CONTAINER2="mail_dnsbl_disabled" CONTAINER2="mail_dnsbl_disabled"

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG PRIVATE_ETC local PRIVATE_CONFIG PRIVATE_ETC

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Test case # Test case
# --------- # ---------

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup() { setup() {
# Getting mail container IP # Getting mail container IP

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Test case # Test case
# --------- # ---------

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
docker run --rm -d --name mail_smtponly \ docker run --rm -d --name mail_smtponly \

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Test case # Test case
# --------- # ---------

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,5 +1,5 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
load 'test_helper/tls' load "${REPOSITORY_ROOT}/test/test_helper/tls"
# Globals referenced from `test_helper/common`: # Globals referenced from `test_helper/common`:
# TEST_NAME TEST_FQDN TEST_TMP_CONFIG # TEST_NAME TEST_FQDN TEST_TMP_CONFIG

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
# Internal copies made by `start-mailserver.sh`: # Internal copies made by `start-mailserver.sh`:

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Test case # Test case
# --------- # ---------

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup() { function setup() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
pushd test/docker-openldap/ || return 1 pushd test/docker-openldap/ || return 1

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup() { function setup() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
# We use a temporary config directory since we'll be dynamically editing # We use a temporary config directory since we'll be dynamically editing

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
function setup_file() { function setup_file() {
# Fail early if the test image is already running: # Fail early if the test image is already running:

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
export IMAGE_NAME CONTAINER_NAME TEST_FILE export IMAGE_NAME CONTAINER_NAME TEST_FILE

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
NON_DEFAULT_DOCKER_MAIL_NETWORK_NAME=non-default-docker-mail-network NON_DEFAULT_DOCKER_MAIL_NETWORK_NAME=non-default-docker-mail-network
setup_file() { setup_file() {

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Globals ${BATS_TMPDIR} and ${NAME} # Globals ${BATS_TMPDIR} and ${NAME}
# `${NAME}` defaults to `mailserver-testing:ci` # `${NAME}` defaults to `mailserver-testing:ci`

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
CONTAINER='sedfile' CONTAINER='sedfile'
TEST_FILE='/tmp/sedfile-test.txt' TEST_FILE='/tmp/sedfile-test.txt'

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
# Globals referenced from `test_helper/common`: # Globals referenced from `test_helper/common`:
# TEST_NAME (should match the filename, minus the bats extension) # TEST_NAME (should match the filename, minus the bats extension)

View file

@ -1,6 +1,4 @@
load 'test_helper/bats-support/load' load "${REPOSITORY_ROOT}/test/test_helper/common"
load 'test_helper/bats-assert/load'
load 'test_helper/common'
@test "repeat_until_success_or_timeout returns instantly on success" { @test "repeat_until_success_or_timeout returns instantly on success" {
SECONDS=0 SECONDS=0

View file

@ -1,4 +1,4 @@
load 'test_helper/common' load "${REPOSITORY_ROOT}/test/test_helper/common"
setup_file() { setup_file() {
local PRIVATE_CONFIG local PRIVATE_CONFIG