git » chasquid » commit 9d78428

test: Make t-04-aliases fail on unexpected mail

author Alberto Bertogli
2023-09-24 08:07:35 UTC
committer Alberto Bertogli
2023-09-24 08:08:23 UTC
parent f51b449c6937eec2bddcd3936f790006736d7bc7

test: Make t-04-aliases fail on unexpected mail

Today we check the aliases deliver mail to the expected locations, but
we don't fail if there are unexpected deliveries.

Doing so can help catch bugs (including test bugs), so this patch
implements that.

In addition, fix two of the tests that were printing on error, but not
causing the tests to fail (which was the original intention).

test/t-04-aliases/run.sh +5 -2

diff --git a/test/t-04-aliases/run.sh b/test/t-04-aliases/run.sh
index c88711f..1eb9573 100755
--- a/test/t-04-aliases/run.sh
+++ b/test/t-04-aliases/run.sh
@@ -21,6 +21,9 @@ function send_and_check() {
 		mail_diff content ".mail/$i@testserver"
 		rm -f ".mail/$i@testserver"
 	done
+	if ! [ -z "$(ls .mail/)" ]; then
+		fail "unexpected mail was delivered: $(ls .mail/)"
+	fi
 }
 
 # Remove the hooks that could be left over from previous failed tests.
@@ -58,12 +61,12 @@ mail_diff content .data/pipe_alias_worked
 
 # Test when alias-resolve exits with an error
 if run_msmtp roto@testserver < content 2> .logs/msmtp.out; then
-	echo "expected delivery to roto@ to fail, but succeeded"
+	fail "expected delivery to roto@ to fail, but succeeded"
 fi
 
 # Test a non-existent alias.
 if run_msmtp nono@testserver < content 2> .logs/msmtp.out; then
-	echo "expected delivery to nono@ to fail, but succeeded"
+	fail "expected delivery to nono@ to fail, but succeeded"
 fi
 
 # Test chasquid-util's ability to do alias resolution talking to chasquid.