]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
tests: split mlmmj-maintd "basic" tests to ease maintenance
authorBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 5 Dec 2022 12:21:03 +0000 (13:21 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 5 Dec 2022 12:22:00 +0000 (13:22 +0100)
tests/mlmmj-maintd.sh

index d9d8a4af24bd62aa93f8c47dd7576507af7bf4ac..b3e29978e24aeccf9b4a899540b27ab776cb9638 100755 (executable)
@@ -17,7 +17,18 @@ tests_init \
        unsub_bouncers_8 \
        unsub_bouncers_9 \
        unsub_bouncers_10 \
-       basics
+       basics_0 \
+       basics_1 \
+       basics_2 \
+       basics_3 \
+       basics_4 \
+       basics_5 \
+       basics_6 \
+       basics_7 \
+       basics_8 \
+       basics_9 \
+       basics_10 \
+       basics_11
 
 nolongerbouncing_body()
 {
@@ -63,10 +74,12 @@ discarded_body()
        atf_check -s exit:0 -o empty -e empty test -f $f2
 }
 
-basics_body()
+basics_0_body()
 {
-
        mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+
        helptxt="Usage: $mlmmjmaintd [-L | -d] /path/to/dir [-F]
  -d: Full path to directory with listdirs
      Use this to run maintenance on all list directories
@@ -76,18 +89,41 @@ basics_body()
      This option should be used when one wants to
      avoid running another daemon, and use e.g. cron to control it instead.
 "
-       mkdir lists
-       init_ml lists/ml
 
        atf_check -s exit:1 -e "inline:mlmmj-maintd: You have to specify -d or -L\n$mlmmjmaintd -h for help\n" $mlmmjmaintd
        atf_check -s exit:1 -e "inline:mlmmj-maintd: You have to specify either -d or -L\n$mlmmjmaintd -h for help\n" $mlmmjmaintd -L lists/ml -d .
        atf_check -s exit:0 -o "match:mlmmj-maintd version" $mlmmjmaintd -V
        atf_check -s exit:0 -o "inline:$helptxt" $mlmmjmaintd -h
+}
+
+basics_1_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
        echo test@mlmmjtest > lists/ml/control/listaddress
+
        atf_check -s exit:1 -e match:"Could not open the directory containing mailing lists.*: No such file or directory" $mlmmjmaintd -F -d nonexisting
+}
+
+basics_2_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
+
        chmod -w lists/ml
        atf_check -s exit:0 -e match:"Could not open maintdlog.* Permission denied" $mlmmjmaintd -F -L lists/ml
-       chmod +w lists/ml
+}
+
+basics_3_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
+
        atf_check -s exit:0 $mlmmjmaintd -L lists/ml -F
        output="Starting maintenance run at
 
@@ -105,8 +141,40 @@ run_digests
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
        rm lists/ml/*.log
+}
+
+basics_4_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
+
+       output="Starting maintenance run at
+
+clean_moderation
+clean_discarded
+clean_subconf
+clean_unsubconf
+resend_queue
+resend_requeue
+clean_nolongerbouncing
+unsub_bouncers
+probe_bouncers
+run_digests
+ - No readable index file: no digest
+"
        atf_check -s exit:0 $mlmmjmaintd -d lists -F
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
+}
+
+basics_5_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
+
        rmdir lists/ml/queue/discarded
        atf_check -s exit:0 -e match:"An error occured while cleaning discarded mails, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
        output="Starting maintenance run at
@@ -125,7 +193,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir lists/ml/queue/discarded
+}
+
+basics_6_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/queue
        atf_check -s exit:0 -e match:"An error occured while cleaning discarded mails, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -146,7 +221,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/queue/discarded
+}
+
+basics_7_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/requeue
        atf_check -s exit:0 -e match:"An error occured while resending requeued mails, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -166,7 +248,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/requeue
+}
+
+basics_8_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/bounce
        atf_check -s exit:0 -e match:"An error occured while cleaning no longer bouncing traces, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -190,7 +279,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/bounce
+}
+
+basics_9_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/subconf
        atf_check -s exit:0 -e match:"An error occured while cleaning subscribtion confirmations, mails, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -210,7 +306,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/subconf
+}
+
+basics_10_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/unsubconf
        atf_check -s exit:0 -e match:"An error occured while cleaning unsubscribtion confirmations, mails, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -230,7 +333,14 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/unsubconf
+}
+
+basics_11_body()
+{
+       mlmmjmaintd=$(command -v mlmmj-maintd)
+       mkdir lists
+       init_ml lists/ml
+       echo test@mlmmjtest > lists/ml/control/listaddress
 
        rm -rf lists/ml/moderation
        atf_check -s exit:0 -e match:"An error occured while cleaning moderation, see mlmmj-maintd.lastrun.log" $mlmmjmaintd -L lists/ml -F
@@ -250,7 +360,6 @@ run_digests
  - No readable index file: no digest
 "
        atf_check -o "inline:$output" sed -e "s/at .*/at/" lists/ml/mlmmj-maintd.lastrun.log
-       mkdir -p lists/ml/moderation
 }
 
 digests_body()