From: Baptiste Daroussin Date: Thu, 5 Jan 2023 08:03:14 +0000 (+0100) Subject: mlmmj-list: add simple testsuite X-Git-Tag: RELEASE_1_4_0_a2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc5fcd3ba4ae9cc96d8c85c85641038477de24b4;p=thirdparty%2Fmlmmj.git mlmmj-list: add simple testsuite --- diff --git a/tests/Kyuafile.in b/tests/Kyuafile.in index 81ebfc5a..235e580e 100644 --- a/tests/Kyuafile.in +++ b/tests/Kyuafile.in @@ -8,3 +8,4 @@ atf_test_program{name='functional-tests'} atf_test_program{name='mlmmj-maintd'} atf_test_program{name='mlmmj-sub'} atf_test_program{name='mlmmj-bounce'} +atf_test_program{name='mlmmj-list'} diff --git a/tests/Makefile.am b/tests/Makefile.am index 2ecd69f6..10e4ad49 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,8 @@ test_scripts = mlmmj-send.sh \ functional-tests.sh \ mlmmj-maintd.sh \ mlmmj-sub.sh \ - mlmmj-bounce.sh + mlmmj-bounce.sh \ + mlmmj-list.sh check_SCRIPTS= $(test_scripts:.sh=) SUFFIXES= .sh diff --git a/tests/mlmmj-list.sh b/tests/mlmmj-list.sh new file mode 100755 index 00000000..5bbe5775 --- /dev/null +++ b/tests/mlmmj-list.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/test_env.sh + +tests_init \ + basics \ + normal \ + nomail \ + digest \ + moderators \ + owner + +normal_body() +{ + init_ml ml + + atf_check mlmmj-list -L ml -s + atf_check -o "inline:0\n" mlmmj-list -L ml -s -c + + mkdir ml/subscribers.d/j + atf_check mlmmj-list -L ml -s + atf_check -o "inline:0\n" mlmmj-list -L ml -s -c + rmdir ml/subscribers.d/j + + touch ml/subscribers.d/j + atf_check mlmmj-list -L ml -s + atf_check -o "inline:0\n" mlmmj-list -L ml -s -c + + echo "john@doe.org" > ml/subscribers.d/j + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -s + atf_check -o "inline:1\n" mlmmj-list -L ml -s -c + + # check the default + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml + atf_check -o "inline:1\n" mlmmj-list -L ml -c + + echo "jane@doe.org" >> ml/subscribers.d/j + atf_check -o "inline:john@doe.org\njane@doe.org\n" mlmmj-list -L ml + atf_check -o "inline:2\n" mlmmj-list -L ml -c + + echo -n "jack@doe.org" >> ml/subscribers.d/j + atf_check -o "inline:john@doe.org\njane@doe.org\njack@doe.org\n" mlmmj-list -L ml + atf_check -o "inline:3\n" mlmmj-list -L ml -c +} + +nomail_body() +{ + init_ml ml + echo "john@doe.org" > ml/nomailsubs.d/j + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -n + atf_check -o "inline:1\n" mlmmj-list -L ml -n -c +} + +digest_body() +{ + init_ml ml + echo "john@doe.org"> ml/digesters.d/j + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -d + atf_check -o "inline:1\n" mlmmj-list -L ml -d -c +} + +moderators_body() +{ + init_ml ml + echo "john@doe.org"> ml/control/moderators + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -m + atf_check -o "inline:1\n" mlmmj-list -L ml -m -c +} + +owner_body() +{ + init_ml ml + echo "john@doe.org"> ml/control/owner + atf_check -o "inline:john@doe.org\n" mlmmj-list -L ml -o + atf_check -o "inline:1\n" mlmmj-list -L ml -o -c +} + +basics_body() +{ + + helptxt="Usage: mlmmj-list -L /path/to/listdir + [-c] [-d] [-h] [-m] [-n] [-o] [-s] [-V] + -L: Full path to list directory + -c: Print subscriber count + -d: Print for digesters list + -h: This help + -m: Print moderators for list + -n: Print for nomail version of list + -o: Print owner(s) of list + -s: Print normal subscribers (default) + -V: Print version +" + atf_check -s exit:1 -e "inline:mlmmj-list: You have to specify -L\nmlmmj-list -h for help\n" mlmmj-list + atf_check -s exit:1 -e "inline:mlmmj-list: Could not opendir(nonexisting/subscribers.d/);\n" mlmmj-list -L nonexisting + mkdir ml + atf_check -s exit:1 -e "inline:mlmmj-list: Could not opendir(ml/subscribers.d/);\n" mlmmj-list -L ml + atf_check -s exit:0 -o "match:mlmmj-list version .*" mlmmj-list -V + atf_check -s exit:0 -o "inline:$helptxt" mlmmj-list -h +}