]>
diplodocus.org Git - nmh/blob - test/mhstore/test-mhstore
2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"$MH_OBJ_DIR/test/common.sh"
19 expected
="$MH_TEST_DIR/test-mhstore$$.expected"
20 actual
="$MH_TEST_DIR/test-mhstore$$.actual"
24 # check with no options and no current message
25 run_test
'mhstore' 'mhstore: no cur message'
27 # check with no options and current message
28 folder
+inbox
5 > /dev
/null
30 This is message number 5
32 run_test
'mhstore' 'storing message 5 as file 5.txt'
33 check
$expected 5.txt
'keep first'
35 # check with folder and current message
36 run_test
'mhstore +inbox' 'storing message 5 as file 5.txt'
37 check
$expected 5.txt
'keep first'
39 # check with specified message
40 run_test
'mhstore 5' 'storing message 5 as file 5.txt'
41 check
$expected 5.txt
'keep first'
44 run_test
"mhstore -file $MH_TEST_DIR/Mail/inbox/5" \
45 "storing message $MH_TEST_DIR/Mail/inbox/5 as file 5.txt"
46 check
$expected 5.txt
'keep first'
49 stored_contents
=`mhstore -file - < $MH_TEST_DIR/Mail/inbox/5 2>&1 | \
51 check
$expected $stored_contents 'keep first'
55 mhstore
5 -outfile "$actual" 2>&1 | grep -v '^storing'
57 check
$expected "$actual" 'keep first'
60 echo 'storing message 5 to stdout' >> "$expected"
61 mhstore
5 -outfile - >"$actual" 2>&1
62 check
$expected "$actual"
64 # check message number greater than highest
65 run_test
'mhstore 11' "mhstore: message 11 doesn't exist"
67 # check multiple messages
68 run_test
'mhstore 4 6' 'storing message 4 as file 4.txt
69 storing message 6 as file 6.txt'
71 This is message number 4
75 This is message number 6
79 # Write message with a text/plain subpart.
82 To: recipient@example.com
83 From: sender@example.com
86 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
89 Content-Type: multipart/related;
90 type="multipart/alternative";
91 boundary="subpart__1.1"
94 Content-Type: text/plain; charset="iso-8859-1"
95 Content-Disposition: attachment; filename="test1.txt"
97 This is the first text/plain part, in a subpart.
101 ------- =_aaaaaaaaaa0
102 Content-Type: text/plain; charset="iso-8859-1"
103 Content-Disposition: attachment; filename="test2.txt"
104 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
105 Content-Transfer-Encoding: quoted-printable
107 This is the second text/plain part.
109 ------- =_aaaaaaaaaa0
110 Content-Type: text/plain; charset="iso-8859-1"
111 Content-Disposition: attachment; filename="test3.txt"
113 This is the third text/plain part.
115 ------- =_aaaaaaaaaa0
116 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
117 Content-Disposition: attachment; filename="test4.txt"
118 Content-Transfer-Encoding: base64
120 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
122 ------- =_aaaaaaaaaa0--
126 cat > $expected <<EOF
127 This is the third text/plain part.
129 run_test
'mhstore last -part 3' 'storing message 11 part 3 as file 11.3.txt'
130 check
$expected 11.3.txt
132 # check -part of a subpart
133 cat > $expected <<EOF
134 This is the first text/plain part, in a subpart.
136 run_test
'mhstore last -part 1.1' \
137 'storing message 11 part 1.1 as file 11.1.1.txt'
138 check
$expected 11.1.1.txt
'keep first'
141 run_test
'mhstore last -type text/plain' \
142 'storing message 11 part 1.1 as file 11.1.1.txt
143 storing message 11 part 2 as file 11.2.txt
144 storing message 11 part 3 as file 11.3.txt
145 storing message 11 part 4 as file 11.4.txt'
146 check
$expected 11.1.1.txt
147 cat > $expected <<EOF
148 This is the second text/plain part.
150 check
$expected 11.2.txt
151 cat > $expected <<EOF
152 This is the third text/plain part.
154 check
$expected 11.3.txt
155 cat > $expected <<EOF
156 This is the fourth text/plain part.
158 check
$expected 11.4.txt
161 cat > $expected <<EOF
162 This is the fourth text/plain part.
164 run_test
'mhstore last -part 4 -auto' \
165 'storing message 11 part 4 as file test4.txt'
166 check
$expected test4.txt
'keep first'
168 # check -noauto, the default
169 run_test
'mhstore last -part 4 -auto -noauto' \
170 'storing message 11 part 4 as file 11.4.txt'
171 check
$expected 11.4.txt
'keep first'
173 # check -verbose, which doesn't do anything
174 run_test
'mhstore last -part 4 -verbose' \
175 'storing message 11 part 4 as file 11.4.txt'
176 check
$expected 11.4.txt
'keep first'
178 # check -noverbose, the default
179 run_test
'mhstore last -part 4 -verbose -noverbose' \
180 'storing message 11 part 4 as file 11.4.txt'
181 check
$expected 11.4.txt
183 # check that -auto obeys Content-Disposition header
184 cat > $expected <<EOF
185 This is the first text/plain part, in a subpart.
187 run_test
'mhstore last -part 1.1 -auto' \
188 'storing message 11 part 1.1 as file test1.txt'
189 check
$expected test1.txt
192 cat > $expected <<EOF
193 This is the second text/plain part.
195 run_test
'mhstore last -part 2 -check' \
196 'storing message 11 part 2 as file 11.2.txt'
197 check
$expected 11.2.txt
'keep first'
199 # check -check with bad MD5 checksum
200 sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' $msgfile > $MH_TEST_DIR/$$.tmp
201 mv -f $MH_TEST_DIR/$$.tmp
$msgfile
202 run_test
'mhstore last -part 2 -check' \
203 'storing message 11 part 2 as file 11.2.txt
204 mhstore: content integrity suspect (digest mismatch) -- continuing
205 (content text/plain in message 11, part 2)'
206 check
$expected 11.2.txt
'keep first'
208 # check -nocheck, the default
209 run_test
'mhstore last -part 2 -check -nocheck' \
210 'storing message 11 part 2 as file 11.2.txt'
211 check
$expected 11.2.txt
213 # check reassembly of message/partial messages (RFC 1521, 7.3.2)
216 To: recipient@example.com
217 From: sender@example.com
220 Content-Type: message/partial; id="test-mhstore message/partial test"; number=1
222 Content-Type: text/plain; charset="iso-8859-1"
224 This is part one of three.
229 To: recipient@example.com
230 From: sender@example.com
233 Content-Type: message/partial; id="test-mhstore message/partial test"; number=2
235 This is part two of three.
240 To: recipient@example.com
241 From: sender@example.com
244 Content-Type: message/partial; id="test-mhstore message/partial test"; number=3;
247 This is part three of three.
250 run_test
'mhstore last:3' \
251 'reassembling partials 12,13,14 to folder inbox as message 15'
253 cat > $expected <<EOF
254 This is part one of three.
255 This is part two of three.
256 This is part three of three.
258 run_test
'mhstore last' 'storing message 15 as file 15.txt'
259 check
$expected 15.txt
261 # cd into Mail directory because it gets cleaned up by the exit trap.
264 # check -clobber always
265 folder
+inbox
7 > /dev
/null
267 cat > $expected <<EOF
268 This is message number 7
270 run_test
'mhstore' 'storing message 7 as file 7.txt'
271 check
$expected 7.txt
'keep first'
272 run_test
'mhstore -clobber ask -clobber always' \
273 'storing message 7 as file 7.txt'
274 check
$expected 7.txt
'keep first'
276 # check -clobber auto
278 run_test
'mhstore -clobber auto' 'storing message 7 as file 7-1.txt'
279 check
$expected 7-1.txt
'keep first'
281 run_test
'mhstore -clobber auto' 'storing message 7 as file 7-2.txt'
282 check
$expected 7-2.txt
'keep first'
284 # check -clobber suffix
285 run_test
'mhstore -clobber suffix' 'storing message 7 as file 7.txt.1'
286 check
$expected 7.txt
.1 'keep first'
288 run_test
'mhstore -clobber suffix' 'storing message 7 as file 7.txt.2'
289 check
$expected 7.txt
.2 'keep first'
291 # Don't check -clobber ask because it requires connection to a
292 # terminal, and this test won't always be run with one.
294 # check -clobber never. Its exit status is the number of files not overwritten.
295 run_test
'mhstore -clobber never' \
296 "mhstore: will not overwrite `pwd`/7.txt with -clobber never"
298 mhstore
-clobber never
>/dev
/null
2>&1
304 # check with relative nmh-storage profile component
305 storagedir
=storagedir
306 dir
="$MH_TEST_DIR/Mail/inbox/$storagedir"
308 echo "nmh-storage: $storagedir" >> $MH
309 cat > $expected <<EOF
310 This is the fourth text/plain part.
312 run_test
'mhstore 11 -part 4' \
313 "storing message 11 part 4 as file $storagedir/11.4.txt"
314 check
$expected "$dir/11.4.txt" 'keep first'
316 # check with relative nmh-storage profile component and -auto
317 run_test
'mhstore 11 -part 4 -auto' \
318 "storing message 11 part 4 as file $storagedir/test4.txt"
319 check
$expected "$dir/test4.txt" 'keep first'
321 # check with absolute nmh-storage profile component
322 absstoragedir
="$MH_TEST_DIR/$storagedir"
323 mkdir "$absstoragedir"
324 sed "s%\(nmh-storage: \)storagedir%\1$absstoragedir%" $MH > $MH.new
326 run_test
'mhstore 11 -part 4' \
327 "storing message 11 part 4 as file $storagedir/11.4.txt"
328 check
$expected "$absstoragedir/11.4.txt" 'keep first'
330 # check with absolute nmh-storage profile component and -auto
331 run_test
'mhstore 11 -part 4 -auto' \
332 "storing message 11 part 4 as file $storagedir/test4.txt"
333 check
$expected "$absstoragedir/test4.txt"
334 rmdir "$absstoragedir"