From 0d5f550bdf22ab21bb7a852861221ae0b82264e1 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Fri, 12 Aug 2022 11:09:17 +1200 Subject: [PATCH] tests: Update submodules for bats (#2715) * tests: Update testing submodules (bats-assert, bats-support) These two submodules were migrated to the `bats-core` organization, where they continued to receive updates. * tests: Use tagged release of `bats-core/bats-support` This is technically one commit backwards, but no relevant difference has been made since, other than moving the submodule to the `bats-core` organization. * tests: Bump `bats-assert` to August 2022 (master) No official release tag since Nov 2018, but a fair amount of changes since then. * tests: Bump `bats-core` to `v1.7.0` release * tests(fix): Correctly use assertions Some tests were updated as the upgrade of bats submodules had `assert` methods raise awareness of incorrect usage. This additionally revealed some existing tests that weren't meant to be using `run`, which swallowed failures from surfacing. --- .gitmodules | 4 ++-- test/bats | 2 +- test/setup-cli.bats | 19 +++++++------------ test/test_helper/bats-assert | 2 +- test/test_helper/bats-support | 2 +- test/tests.bats | 3 +-- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.gitmodules b/.gitmodules index 52afd00b..fc82d31f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,10 +3,10 @@ url = https://github.com/bats-core/bats-core.git [submodule "test/test_helper/bats-support"] path = test/test_helper/bats-support - url = https://github.com/ztombol/bats-support + url = https://github.com/bats-core/bats-support [submodule "test/test_helper/bats-assert"] path = test/test_helper/bats-assert - url = https://github.com/ztombol/bats-assert + url = https://github.com/bats-core/bats-assert [submodule "target/docker-configomat"] path = target/docker-configomat url = https://github.com/alinmear/docker-configomat diff --git a/test/bats b/test/bats index 54e965fa..410dd229 160000 --- a/test/bats +++ b/test/bats @@ -1 +1 @@ -Subproject commit 54e965fa9d269c2b3ff9036d81f32bac3df0edea +Subproject commit 410dd229a5ed005c68167cc90ed0712ad2a1c909 diff --git a/test/setup-cli.bats b/test/setup-cli.bats index 069488b1..0c7848b8 100644 --- a/test/setup-cli.bats +++ b/test/setup-cli.bats @@ -31,14 +31,12 @@ function teardown_file() { @test "checking setup.sh: setup.sh email add and login" { wait_for_service "${TEST_NAME}" changedetector - assert_success run ./setup.sh -c "${TEST_NAME}" email add setup_email_add@example.com test_password assert_success value=$(grep setup_email_add@example.com "${TEST_TMP_CONFIG}/postfix-accounts.cf" | awk -F '|' '{print $1}') - [[ ${value} == "setup_email_add@example.com" ]] - assert_success + assert_equal "${value}" 'setup_email_add@example.com' wait_for_changes_to_be_detected_in_container "${TEST_NAME}" @@ -60,8 +58,7 @@ function teardown_file() { assert_success initialpass=$(grep lorem@impsum.org "${TEST_TMP_CONFIG}/postfix-accounts.cf" | awk -F '|' '{print $2}') - [[ ${initialpass} != "" ]] - assert_success + [[ -n ${initialpass} ]] run ./setup.sh -c "${TEST_NAME}" email update lorem@impsum.org my password assert_success @@ -70,8 +67,8 @@ function teardown_file() { [[ ${updatepass} != "" ]] [[ ${initialpass} != "${updatepass}" ]] - docker exec "${TEST_NAME}" doveadm pw -t "${updatepass}" -p 'my password' | grep 'verified' - assert_success + run docker exec "${TEST_NAME}" doveadm pw -t "${updatepass}" -p 'my password' + assert_output --partial 'verified' } @test "checking setup.sh: setup.sh email del" { @@ -151,8 +148,8 @@ function teardown_file() { # quota @test "checking setup.sh: setup.sh setquota" { - run ./setup.sh -c "${TEST_NAME}" email add quota_user@example.com test_password - run ./setup.sh -c "${TEST_NAME}" email add quota_user2@example.com test_password + ./setup.sh -c "${TEST_NAME}" email add quota_user@example.com test_password + ./setup.sh -c "${TEST_NAME}" email add quota_user2@example.com test_password run ./setup.sh -c "${TEST_NAME}" quota set quota_user@example.com 12M assert_success @@ -176,10 +173,8 @@ function teardown_file() { assert_failure } +# `quota_user@example.com` created in previous `setquota` test @test "checking setup.sh: setup.sh delquota" { - run ./setup.sh -c "${TEST_NAME}" email add quota_user@example.com test_password - run ./setup.sh -c "${TEST_NAME}" email add quota_user2@example.com test_password - run ./setup.sh -c "${TEST_NAME}" quota set quota_user@example.com 12M assert_success run /bin/sh -c "cat ${TEST_TMP_CONFIG}/dovecot-quotas.cf | grep -E '^quota_user@example.com\:12M\$' | wc -l | grep 1" diff --git a/test/test_helper/bats-assert b/test/test_helper/bats-assert index 9f88b420..ffe84ea5 160000 --- a/test/test_helper/bats-assert +++ b/test/test_helper/bats-assert @@ -1 +1 @@ -Subproject commit 9f88b4207da750093baabc4e3f41bf68f0dd3630 +Subproject commit ffe84ea5dd43b568851549b3e241db150c12929c diff --git a/test/test_helper/bats-support b/test/test_helper/bats-support index 004e7076..24a72e14 160000 --- a/test/test_helper/bats-support +++ b/test/test_helper/bats-support @@ -1 +1 @@ -Subproject commit 004e707638eedd62e0481e8cdc9223ad471f12ee +Subproject commit 24a72e14349690bcbf7c151b9d2d1cdd32d36eb1 diff --git a/test/tests.bats b/test/tests.bats index dcd71aca..2f51bd61 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -649,8 +649,7 @@ EOF [[ ${initialpass} != "${changepass}" ]] - docker exec mail /bin/sh -c "delmailuser -y auser3@domain.tld" - + run docker exec mail /bin/sh -c "delmailuser -y auser3@domain.tld" assert_success }