]> diplodocus.org Git - nmh/blob - test/mhshow/test-subpart
Merge remote-tracking branch 'origin' into convertargs
[nmh] / test / mhshow / test-subpart
1 #!/bin/sh
2 ######################################################
3 #
4 # Test show of one part, fixed by
5 # 31cba404636730df219dd009ca5893ccc56d46af
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname "$0"`/../..
13 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "$MH_OBJ_DIR/test/common.sh"
17
18 setup_test
19
20 expected=$MH_TEST_DIR/$$.expected
21 actual=$MH_TEST_DIR/$$.actual
22
23 # Write message with a text/plain subpart.
24 msgfile=`mhpath new`
25 msgnum=`basename $msgfile`
26 cat > $msgfile <<EOF
27 MIME-Version: 1.0
28 Content-Type: multipart/mixed; boundary="NextPart_001"
29 Content-class: urn:content-classes:message
30 Date: Thu, 19 May 2011 00:00:00 -0000
31 From: sender@example.com
32 To: recipient@example.com
33
34 This is a multi-part message in MIME format.
35
36 --NextPart_001
37 Content-Type: multipart/related;
38 type="multipart/alternative";
39 boundary="NextPart_002"
40
41 --NextPart_002
42 Content-Type: text/plain;
43 charset="utf-8"
44
45 This is the text/plain part.
46
47 --NextPart_002--
48
49 --NextPart_001--
50 EOF
51
52 # Write the expected output.
53 cat > $expected <<EOF
54 [ part 1.1 - text/plain - 29B ]
55 This is the text/plain part.
56 EOF
57
58 # check it
59 run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
60 check "$expected" "$actual"
61
62 cat > $msgfile <<EOF
63 To: example@example.org
64 From: someone <someone@example.com>
65 Subject: mhshow -part/-type/prefer test
66 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
67 Content-Type: multipart/mixed; boundary="BoundaryMixed"
68
69 --BoundaryMixed
70 Content-type: multipart/alternative;
71 boundary="BoundaryAlternative1"
72
73 --BoundaryAlternative1
74 Content-type: text/plain; charset=ISO-8859-1; format=flowed
75 Content-transfer-encoding: 8bit
76
77 This is the body text/plain part.
78 --BoundaryAlternative1
79 Content-type: multipart/related;
80 boundary="BoundaryAlternative2"; type="text/html"
81
82 --BoundaryAlternative2
83 Content-type: text/html; CHARSET=US-ASCII
84 Content-transfer-encoding: quoted-printable
85
86 <html><body><div><span style=3D"line-height: 1.5;">
87 This is the text/html body part.
88 </span></div></body></html>
89
90 --BoundaryAlternative2--
91
92 --BoundaryAlternative1--
93
94 --BoundaryMixed
95 Content-Type: text/plain; charset="us-ascii"
96 MIME-Version: 1.0
97 Content-Transfer-Encoding: 7bit
98 Content-Disposition: inline
99
100 _______________________________________________
101 This is the final text/plain signature part.
102
103 --BoundaryMixed--
104 EOF
105
106 # Write the expected output.
107 cat > $expected <<EOF
108 [ part 1.1.1 - text/html - 111B ]
109 This is the text/html body part.
110 EOF
111
112 # check it
113 run_prog mhshow -part 1.1.1 -form mhl.null $msgnum > $actual 2>&1
114 check "$expected" "$actual"
115
116 # Write the expected output.
117 cat > $expected <<EOF
118 [ part 1.2 - text/plain - 33B ]
119 This is the body text/plain part.
120 EOF
121
122 # check it
123 run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
124 check "$expected" "$actual"
125
126 # Write the expected output.
127 cat > $expected <<EOF
128 [ part 1.1 - text/plain - 33B ]
129 This is the body text/plain part.
130 EOF
131
132 # check it
133 run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
134 check "$expected" "$actual"
135
136 # Write the expected output.
137 cat > $expected <<EOF
138 [ part 2 - text/plain - 93B ]
139 _______________________________________________
140 This is the final text/plain signature part.
141 EOF
142
143 # check it
144 run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
145 check "$expected" "$actual"
146
147 # Write the expected output.
148 cat > $expected <<EOF
149 [ part 1.2 - text/plain - 33B ]
150 This is the body text/plain part.
151 [ part 2 - text/plain - 93B ]
152 _______________________________________________
153 This is the final text/plain signature part.
154 EOF
155
156 # check it
157 run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
158 check "$expected" "$actual"
159
160 # Write the expected output.
161 cat > $expected <<EOF
162 [ part 1.1 - text/plain - 33B ]
163 This is the body text/plain part.
164 [ part 2 - text/plain - 93B ]
165 _______________________________________________
166 This is the final text/plain signature part.
167 EOF
168
169 run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
170 check "$expected" "$actual"
171
172 exit $failed