Rework in the test framework; updated and new tests
[mmh] / test / tests / rcv / test-rcvstore
1 #!/bin/sh
2 ######################################################
3 #
4 # Test rcvstore
5 #
6 ######################################################
7
8 . "$MH_TEST_COMMON"
9
10
11 # check -help
12 runandcheck "rcvstore -help" <<!
13 Usage: rcvstore [+folder] [switches]
14   switches are:
15   -[no]create
16   -[no]unseen
17   -[no]public
18   -[no]zero
19   -sequence name
20   -Version
21   -help
22 !
23
24
25 # check -version
26 case `rcvstore -V` in
27   rcvstore\ --*) ;;
28   *            ) printf '%s: rcvstore -V generated unexpected output\n' "$0" >&2
29                  failed=`expr ${failed:-0} + 1`;;
30 esac
31
32
33 # check unknown switch
34 runandcheck "rcvstore -nonexistent" <<!
35 rcvstore: -nonexistent unknown
36 !
37
38
39 # check with no switches and zero-length input message
40 runandcheck "rcvstore </dev/null" <<!
41 rcvstore: empty file
42 !
43
44
45 # check with no switches
46 runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
47 !
48 diff -u "`mhpath +inbox f`" "`mhpath l`"
49
50
51 # check + of existing folder
52 runandcheck "rcvstore +inbox <$MH_TEST_DIR/Mail/inbox/1" <<!
53 !
54 diff -u "`mhpath f`" "`mhpath l`"
55
56
57 # check + of new folder
58 runandcheck "rcvstore +newfolder <$MH_TEST_DIR/Mail/inbox/1" <<!
59 !
60 diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
61 rmf "+newfolder"
62
63
64 # check -nocreate
65 runandcheck "rcvstore +newfolder -nocreate <$MH_TEST_DIR/Mail/inbox/1" <<!
66 rcvstore: folder $MH_TEST_DIR/Mail/newfolder doesn't exist
67 !
68
69
70 # check -create
71 runandcheck "rcvstore +newfolder -nocreate -create <$MH_TEST_DIR/Mail/inbox/1" <<!
72 !
73 diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
74 rmf "+newfolder"
75
76
77 # check addition to unseen sequence
78 runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
79 !
80 runandcheck 'mark -sequence u -list' <<!
81 u: 11-13
82 !
83 diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
84
85
86
87 # check -nounseen
88 runandcheck "rcvstore -nounseen <$MH_TEST_DIR/Mail/inbox/1" <<!
89 !
90 runandcheck 'mark -sequence u -list' <<!
91 u: 11-13
92 !
93 diff -u "`mhpath f`" "`mhpath l`"
94
95
96 # check -unseen
97 runandcheck "rcvstore -nounseen -unseen <$MH_TEST_DIR/Mail/inbox/1" <<!
98 !
99 runandcheck 'mark -sequence u -list' <<!
100 u: 11-13 15
101 !
102 diff -u "`mhpath f`" "`mhpath l`"
103
104
105 # check -sequence
106 runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
107 !
108 runandcheck 'mark -sequence newseq -list' <<!
109 newseq: 16
110 !
111 diff -u "`mhpath f`" "`mhpath l`"
112
113
114 # check that default is -nozero
115 mark -sequence newseq a
116 runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
117 !
118 runandcheck 'mark -sequence newseq -list' <<!
119 newseq: 1-17
120 !
121 diff -u "`mhpath f`" "`mhpath l`"
122
123
124 # check -zero
125 mark -sequence newseq a
126 runandcheck "rcvstore -sequence newseq -zero <$MH_TEST_DIR/Mail/inbox/1" <<!
127 !
128 runandcheck 'mark -sequence newseq -list' <<!
129 newseq: 18
130 !
131 diff -u "`mhpath f`" "`mhpath l`"
132
133
134 # check -nozero
135 mark -sequence newseq a
136 runandcheck "rcvstore -sequence newseq -zero -nozero <$MH_TEST_DIR/Mail/inbox/1" <<!
137 !
138 runandcheck 'mark -sequence newseq -list' <<!
139 newseq: 1-19
140 !
141 diff -u "`mhpath f`" "`mhpath l`"
142
143
144 # check that default is -public
145 runandcheck "rcvstore -sequence pubseq <$MH_TEST_DIR/Mail/inbox/1" <<!
146 !
147 runandcheck 'mark -sequence pubseq -list' <<!
148 pubseq: 20
149 !
150 diff -u "`mhpath f`" "`mhpath l`"
151
152 # check -nopublic
153 runandcheck "rcvstore -sequence privseq -nopublic <$MH_TEST_DIR/Mail/inbox/1" <<!
154 !
155 runandcheck 'mark -sequence privseq -nopublic -list' <<!
156 privseq (private): 21
157 !
158 diff -u "`mhpath f`" "`mhpath l`"
159
160 # check -public
161 runandcheck "rcvstore -sequence pubseq -nopublic -public <$MH_TEST_DIR/Mail/inbox/1" <<!
162 !
163 runandcheck 'mark -sequence pubseq -public -list' <<!
164 pubseq: 20 22
165 !
166 diff -u "`mhpath f`" "`mhpath l`"
167
168
169 # check default Msg-Protect
170 msgprot="`mhparam msgprot`"
171 runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
172 !
173 runandcheck "find $MH_TEST_DIR/Mail/inbox/23 -perm $msgprot" <<!
174 $MH_TEST_DIR/Mail/inbox/23
175 !
176 diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
177
178
179 # check Msg-Protect profile entry
180 msgprot=640
181 printf 'Msg-Protect: %s\n' "$msgprot" >>"`mhparam defpath`"
182 runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
183 !
184 runandcheck "find $MH_TEST_DIR/Mail/inbox/24 -perm $msgprot" <<!
185 $MH_TEST_DIR/Mail/inbox/24
186 !
187 diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
188