]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-list: add simple testsuite
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 5 Jan 2023 08:03:14 +0000 (09:03 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 5 Jan 2023 08:03:14 +0000 (09:03 +0100)
tests/Kyuafile.in
tests/Makefile.am
tests/mlmmj-list.sh [new file with mode: 0755]

index 81ebfc5a06a81753741388f59bed45a9dff2f714..235e580eb8328dad0e75fc18f0c0799ea11d7d61 100644 (file)
@@ -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'}
index 2ecd69f629f80f68f1ac16c1c296308e4a14abe1..10e4ad49ad6cf9307fff3f6ebe178281b18650b2 100644 (file)
@@ -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 (executable)
index 0000000..5bbe577
--- /dev/null
@@ -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
+}