]>
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/$$.expected
20 actual
=$MH_TEST_DIR/$$.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
53 # check message number greater than highest
54 run_test
'mhstore 11' "mhstore: message 11 doesn't exist"
56 # check multiple messages
57 run_test
'mhstore 4 6' 'storing message 4 as file 4.txt
58 storing message 6 as file 6.txt'
60 This is message number 4
64 This is message number 6
68 # Write message with a text/plain subpart.
71 To: recipient@example.com
72 From: sender@example.com
75 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
78 Content-Type: multipart/related;
79 type="multipart/alternative";
80 boundary="subpart__1.1"
83 Content-Type: text/plain; charset="iso-8859-1"
84 Content-Disposition: attachment; filename="test1.txt"
86 This is the first text/plain part, in a subpart.
91 Content-Type: text/plain; charset="iso-8859-1"
92 Content-Disposition: attachment; filename="test2.txt"
93 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
94 Content-Transfer-Encoding: quoted-printable
96 This is the second text/plain part.
99 Content-Type: text/plain; charset="iso-8859-1"
100 Content-Disposition: attachment; filename="test3.txt"
102 This is the third text/plain part.
104 ------- =_aaaaaaaaaa0
105 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
106 Content-Disposition: attachment; filename="test4.txt"
107 Content-Transfer-Encoding: base64
109 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
111 ------- =_aaaaaaaaaa0--
115 cat > $expected <<EOF
116 This is the third text/plain part.
118 run_test
'mhstore last -part 3' 'storing message 11 part 3 as file 11.3.txt'
119 check
$expected 11.3.txt
121 # check -part of a subpart
122 cat > $expected <<EOF
123 This is the first text/plain part, in a subpart.
125 run_test
'mhstore last -part 1.1' \
126 'storing message 11 part 1.1 as file 11.1.1.txt'
127 check
$expected 11.1.1.txt
'keep first'
130 run_test
'mhstore last -type text/plain' \
131 'storing message 11 part 1.1 as file 11.1.1.txt
132 storing message 11 part 2 as file 11.2.txt
133 storing message 11 part 3 as file 11.3.txt
134 storing message 11 part 4 as file 11.4.txt'
135 check
$expected 11.1.1.txt
136 cat > $expected <<EOF
137 This is the second text/plain part.
139 check
$expected 11.2.txt
140 cat > $expected <<EOF
141 This is the third text/plain part.
143 check
$expected 11.3.txt
144 cat > $expected <<EOF
145 This is the fourth text/plain part.
147 check
$expected 11.4.txt
150 cat > $expected <<EOF
151 This is the fourth text/plain part.
153 run_test
'mhstore last -part 4 -auto' \
154 'storing message 11 part 4 as file test4.txt'
155 check
$expected test4.txt
'keep first'
157 # check -noauto, the default
158 run_test
'mhstore last -part 4 -auto -noauto' \
159 'storing message 11 part 4 as file 11.4.txt'
160 check
$expected 11.4.txt
'keep first'
162 # check -verbose, which doesn't do anything
163 run_test
'mhstore last -part 4 -verbose' \
164 'storing message 11 part 4 as file 11.4.txt'
165 check
$expected 11.4.txt
'keep first'
167 # check -noverbose, the default
168 run_test
'mhstore last -part 4 -verbose -noverbose' \
169 'storing message 11 part 4 as file 11.4.txt'
170 check
$expected 11.4.txt
172 # check that -auto obeys Content-Disposition header
173 cat > $expected <<EOF
174 This is the first text/plain part, in a subpart.
176 run_test
'mhstore last -part 1.1 -auto' \
177 'storing message 11 part 1.1 as file test1.txt'
178 check
$expected test1.txt
181 cat > $expected <<EOF
182 This is the second text/plain part.
184 run_test
'mhstore last -part 2 -check' \
185 'storing message 11 part 2 as file 11.2.txt'
186 check
$expected 11.2.txt
'keep first'
188 # check -check with bad MD5 checksum
189 sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' $msgfile > $MH_TEST_DIR/$$.tmp
190 mv -f $MH_TEST_DIR/$$.tmp
$msgfile
191 run_test
'mhstore last -part 2 -check' \
192 'storing message 11 part 2 as file 11.2.txt
193 mhstore: content integrity suspect (digest mismatch) -- continuing
194 (content text/plain in message 11, part 2)'
195 check
$expected 11.2.txt
'keep first'
197 # check -nocheck, the default
198 run_test
'mhstore last -part 2 -check -nocheck' \
199 'storing message 11 part 2 as file 11.2.txt'
200 check
$expected 11.2.txt
202 # check reassembly of message/partial messages (RFC 1521, 7.3.2)
205 To: recipient@example.com
206 From: sender@example.com
209 Content-Type: message/partial; id="test-mhstore message/partial test"; number=1
211 Content-Type: text/plain; charset="iso-8859-1"
213 This is part one of three.
218 To: recipient@example.com
219 From: sender@example.com
222 Content-Type: message/partial; id="test-mhstore message/partial test"; number=2
224 This is part two of three.
229 To: recipient@example.com
230 From: sender@example.com
233 Content-Type: message/partial; id="test-mhstore message/partial test"; number=3;
236 This is part three of three.
239 run_test
'mhstore last:3' \
240 'reassembling partials 12,13,14 to folder inbox as message 15'
242 cat > $expected <<EOF
243 This is part one of three.
244 This is part two of three.
245 This is part three of three.
247 run_test
'mhstore last' 'storing message 15 as file 15.txt'
248 check
$expected 15.txt
250 # cd into Mail directory because it gets cleaned up by the exit trap.
253 # check -clobber always
254 folder
+inbox
7 > /dev
/null
256 cat > $expected <<EOF
257 This is message number 7
259 run_test
'mhstore' 'storing message 7 as file 7.txt'
260 check
$expected 7.txt
'keep first'
261 run_test
'mhstore -clobber ask -clobber always' \
262 'storing message 7 as file 7.txt'
263 check
$expected 7.txt
'keep first'
265 # check -clobber auto
267 run_test
'mhstore -clobber auto' 'storing message 7 as file 7-1.txt'
268 check
$expected 7-1.txt
'keep first'
270 run_test
'mhstore -clobber auto' 'storing message 7 as file 7-2.txt'
271 check
$expected 7-2.txt
'keep first'
273 # check -clobber suffix
274 run_test
'mhstore -clobber suffix' 'storing message 7 as file 7.txt.1'
275 check
$expected 7.txt
.1 'keep first'
277 run_test
'mhstore -clobber suffix' 'storing message 7 as file 7.txt.2'
278 check
$expected 7.txt
.2 'keep first'
280 # Don't check -clobber ask because it requires connection to a
281 # terminal, and this test won't always be run with one.
283 # check -clobber never. Its exit status is the number of files not overwritten.
284 run_test
'mhstore -clobber never' \
285 "mhstore: will not overwrite `pwd`/7.txt with -clobber never"
287 mhstore
-clobber never
>/dev
/null
2>&1
293 # check with relative nmh-storage profile component
294 storagedir
=storagedir
295 dir
="$MH_TEST_DIR/Mail/inbox/$storagedir"
297 echo "nmh-storage: $storagedir" >> $MH
298 cat > $expected <<EOF
299 This is the fourth text/plain part.
301 run_test
'mhstore 11 -part 4' \
302 "storing message 11 part 4 as file $storagedir/11.4.txt"
303 check
$expected "$dir/11.4.txt" 'keep first'
305 # check with relative nmh-storage profile component and -auto
306 run_test
'mhstore 11 -part 4 -auto' \
307 "storing message 11 part 4 as file $storagedir/test4.txt"
308 check
$expected "$dir/test4.txt" 'keep first'
310 # check with absolute nmh-storage profile component
311 absstoragedir
="$MH_TEST_DIR/$storagedir"
312 mkdir "$absstoragedir"
313 sed "s%\(nmh-storage: \)storagedir%\1$absstoragedir%" $MH > $MH.new
315 run_test
'mhstore 11 -part 4' \
316 "storing message 11 part 4 as file $storagedir/11.4.txt"
317 check
$expected "$absstoragedir/11.4.txt" 'keep first'
319 # check with absolute nmh-storage profile component and -auto
320 run_test
'mhstore 11 -part 4 -auto' \
321 "storing message 11 part 4 as file $storagedir/test4.txt"
322 check
$expected "$absstoragedir/test4.txt"
323 rmdir "$absstoragedir"