Rework in the test framework; updated and new tests
[mmh] / test / tests / rcv / test-rcvstore
diff --git a/test/tests/rcv/test-rcvstore b/test/tests/rcv/test-rcvstore
new file mode 100755 (executable)
index 0000000..fba32b9
--- /dev/null
@@ -0,0 +1,188 @@
+#!/bin/sh
+######################################################
+#
+# Test rcvstore
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# check -help
+runandcheck "rcvstore -help" <<!
+Usage: rcvstore [+folder] [switches]
+  switches are:
+  -[no]create
+  -[no]unseen
+  -[no]public
+  -[no]zero
+  -sequence name
+  -Version
+  -help
+!
+
+
+# check -version
+case `rcvstore -V` in
+  rcvstore\ --*) ;;
+  *            ) printf '%s: rcvstore -V generated unexpected output\n' "$0" >&2
+                 failed=`expr ${failed:-0} + 1`;;
+esac
+
+
+# check unknown switch
+runandcheck "rcvstore -nonexistent" <<!
+rcvstore: -nonexistent unknown
+!
+
+
+# check with no switches and zero-length input message
+runandcheck "rcvstore </dev/null" <<!
+rcvstore: empty file
+!
+
+
+# check with no switches
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath l`"
+
+
+# check + of existing folder
+runandcheck "rcvstore +inbox <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check + of new folder
+runandcheck "rcvstore +newfolder <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
+rmf "+newfolder"
+
+
+# check -nocreate
+runandcheck "rcvstore +newfolder -nocreate <$MH_TEST_DIR/Mail/inbox/1" <<!
+rcvstore: folder $MH_TEST_DIR/Mail/newfolder doesn't exist
+!
+
+
+# check -create
+runandcheck "rcvstore +newfolder -nocreate -create <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
+rmf "+newfolder"
+
+
+# check addition to unseen sequence
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+
+
+
+# check -nounseen
+runandcheck "rcvstore -nounseen <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -unseen
+runandcheck "rcvstore -nounseen -unseen <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13 15
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -sequence
+runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 16
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check that default is -nozero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 1-17
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -zero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq -zero <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 18
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -nozero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq -zero -nozero <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 1-19
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check that default is -public
+runandcheck "rcvstore -sequence pubseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence pubseq -list' <<!
+pubseq: 20
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+# check -nopublic
+runandcheck "rcvstore -sequence privseq -nopublic <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence privseq -nopublic -list' <<!
+privseq (private): 21
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+# check -public
+runandcheck "rcvstore -sequence pubseq -nopublic -public <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence pubseq -public -list' <<!
+pubseq: 20 22
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check default Msg-Protect
+msgprot="`mhparam msgprot`"
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck "find $MH_TEST_DIR/Mail/inbox/23 -perm $msgprot" <<!
+$MH_TEST_DIR/Mail/inbox/23
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+
+
+# check Msg-Protect profile entry
+msgprot=640
+printf 'Msg-Protect: %s\n' "$msgprot" >>"`mhparam defpath`"
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck "find $MH_TEST_DIR/Mail/inbox/24 -perm $msgprot" <<!
+$MH_TEST_DIR/Mail/inbox/24
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+