git » chasquid » commit def6e1c

dovecot-auth-cli: Test invalid arguments handling

author Alberto Bertogli
2021-01-16 14:38:28 UTC
committer Alberto Bertogli
2021-01-16 23:21:35 UTC
parent 34b1f6cf21693b61945022021c354d0e4408a74d

dovecot-auth-cli: Test invalid arguments handling

This patch adds a minor test to dovecot-auth-cli to verify that the
check for invalid number of arguments is working as expected.

It's mostly for consistency, as the utility is only used for testing
purposes.

cmd/dovecot-auth-cli/dovecot-auth-cli.go +0 -1
cmd/dovecot-auth-cli/test.sh +5 -0

diff --git a/cmd/dovecot-auth-cli/dovecot-auth-cli.go b/cmd/dovecot-auth-cli/dovecot-auth-cli.go
index 10248ec..2a01638 100644
--- a/cmd/dovecot-auth-cli/dovecot-auth-cli.go
+++ b/cmd/dovecot-auth-cli/dovecot-auth-cli.go
@@ -1,7 +1,6 @@
 // CLI used for testing the dovecot authentication package.
 //
 // NOT for production use.
-// +build !coverage
 
 package main
 
diff --git a/cmd/dovecot-auth-cli/test.sh b/cmd/dovecot-auth-cli/test.sh
index 4bb8c4f..c7dc23c 100755
--- a/cmd/dovecot-auth-cli/test.sh
+++ b/cmd/dovecot-auth-cli/test.sh
@@ -16,6 +16,11 @@ else
 	go build $GOFLAGS -tags="$GOTAGS" dovecot-auth-cli.go
 fi
 
+if ! ./dovecot-auth-cli lalala 2>&1 | grep -q "invalid arguments"; then
+	echo "cli worked with invalid arguments"
+	exit 1
+fi
+
 for i in *.cmy; do
 	if ! chamuyero $i > $i.log 2>&1 ; then
 		echo "# Test $i failed, log follows"