]> diplodocus.org Git - nmh/blob - test/comp/test-draft-fcc
expect this commit to be force-replaced periodically
[nmh] / test / comp / test-draft-fcc
1 #!/bin/sh
2
3 if test -z "${MH_OBJ_DIR}"; then
4 srcdir=`dirname "$0"`/../..
5 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
6 fi
7
8 . "${MH_OBJ_DIR}/test/common.sh"
9
10 setup_test
11
12 cat >> "$MH" <<EOF
13 Draft-Folder: drafts
14 Local-Mailbox: norm@example.com
15 EOF
16
17 # Set this for the EHLO command
18 echo "clientname: nosuchhost.example.com" >> ${MHMTSCONF}
19
20 cat > "$MH_TEST_DIR/Mail/scan.dateless" <<EOF
21 %4(msg)%<(cur)+%| %>%<(unseen)U%| %>%<{replied}-%| %>\
22 %<(mymbox{from})%<{to}To:%(unquote(decode(friendly{to})))%>%>\
23 %<(zero)%(unquote(decode(friendly{from})))%> \
24 %(decode{subject})%<{body}<<%{body}>>%>
25 EOF
26
27 sbackup="`mhparam sbackup`"
28
29 arith_eval 64000 + $$ % 1000
30 smtp_port=$arith_val
31
32 expected="$MH_TEST_DIR/$$.expected"
33 actual="$MH_TEST_DIR/$$.actual"
34
35 ################################################################################
36 start_test 'comp with Draft-Folder'
37
38 check_exit '-eq 0' comp -noedit -to phyl@example.com -fcc sent -subject test -nowhatnowproc < /dev/null
39
40 ################################################################################
41 start_test 'scan +drafts shows the draft'
42
43 cat > "$expected" <<EOF
44 1+ To:phyl@example.com test
45 EOF
46
47 run_prog scan -form scan.dateless +drafts > "$actual"
48 check "$actual" "$expected"
49
50 ################################################################################
51 start_test 'send with Draft-Folder'
52
53 pid=`"${MH_OBJ_DIR}/test/fakesmtp" /dev/null $smtp_port`
54
55 if ! (echo y | check_exit '-eq 0' send -server 127.0.0.1 -port $smtp_port); then
56 failed=`expr ${failed:-0} + 1`
57 fi
58 kill $pid 2> /dev/null || :
59 [ ${failed:-0} -eq 0 ]
60
61 ################################################################################
62 start_test 'drafts/.mh_sequences'
63
64 cat > "$expected" <<EOF
65 cur: 1
66 EOF
67 check "`mhpath +drafts`/.mh_sequences" "$expected"
68
69 ################################################################################
70 start_test 'scan +drafts shows no messages'
71
72 cat > "$expected" <<EOF
73 scan: no messages in drafts
74 EOF
75
76 run_prog scan -form scan.dateless +drafts > "$actual" 2>&1 || :
77 check "$actual" "$expected"
78
79 ################################################################################
80 start_test 'scan +sent shows the sent message'
81
82 cat > "$expected" <<EOF
83 1 To:phyl@example.com test
84 EOF
85
86 run_prog scan -form scan.dateless +sent > "$actual"
87 check "$actual" "$expected"
88
89 ################################################################################
90 start_test 'drafts/,1.orig is the original draft'
91
92 cat > "$expected" <<EOF
93 From: norm@example.com
94 To: phyl@example.com
95 cc:
96 Fcc: sent
97 Subject: test
98 --------
99 EOF
100 check "`mhpath +drafts`/,1.orig" "$expected"
101
102 ################################################################################
103 start_test 'drafts/,1 is the post-mhbuild draft'
104
105 cat > "$expected" <<EOF
106 From: norm@example.com
107 To: phyl@example.com
108 cc:
109 Fcc: sent
110 Subject: test
111 MIME-Version: 1.0
112 Content-Type: text/plain
113 EOF
114 check "`mhpath +drafts`/,1" "$expected"
115
116 ################################################################################
117 # Now test with -draftfolder.
118 # TODO Why are these different?!
119 ################################################################################
120
121 ################################################################################
122 start_test 'comp with Draft-Folder now for send -draftfolder'
123
124 check_exit '-eq 0' comp -noedit -to phyl@example.com -fcc sent -subject test2 -nowhatnowproc < /dev/null
125
126 ################################################################################
127 start_test 'scan +drafts shows the draft now for send -draftfolder'
128
129 cat > "$expected" <<EOF
130 1+ To:phyl@example.com test2
131 EOF
132
133 run_prog scan -form scan.dateless +drafts > "$actual"
134 check "$actual" "$expected"
135
136 ################################################################################
137 start_test 'send -draftfolder'
138
139 pid=`"${MH_OBJ_DIR}/test/fakesmtp" /dev/null $smtp_port`
140
141 if ! check_exit '-eq 0' send -draftfolder drafts -server 127.0.0.1 -port $smtp_port < /dev/null; then
142 failed=`expr ${failed:-0} + 1`
143 fi
144 kill $pid 2> /dev/null || :
145 [ ${failed:-0} -eq 0 ]
146
147 ################################################################################
148 start_test 'drafts/.mh_sequences'
149
150 cat > "$expected" <<EOF
151 cur: 1
152 EOF
153 check "`mhpath +drafts`/.mh_sequences" "$expected"
154
155 ################################################################################
156 start_test 'scan +drafts shows no messages now for send -draftfolder'
157
158 cat > "$expected" <<EOF
159 scan: no messages in drafts
160 EOF
161
162 run_prog scan -form scan.dateless +drafts > "$actual" 2>&1 || :
163 check "$actual" "$expected"
164
165 ################################################################################
166 start_test 'scan +sent shows the sent message now for send -draftfolder'
167
168 cat > "$expected" <<EOF
169 1 To:phyl@example.com test
170 2 To:phyl@example.com test2
171 EOF
172
173 run_prog scan -form scan.dateless +sent > "$actual"
174 check "$actual" "$expected"
175
176 ################################################################################
177 start_test "drafts/${sbackup}1.orig is the original draft now for send -draftfolder"
178
179 cat > "$expected" <<EOF
180 From: norm@example.com
181 To: phyl@example.com
182 cc:
183 Fcc: sent
184 Subject: test2
185 --------
186 EOF
187 check "`mhpath +drafts`/${sbackup}1.orig" "$expected"
188
189 ################################################################################
190 start_test "drafts/${sbackup}1 is the post-mhbuild draft now for send -draftfolder"
191
192 cat > "$expected" <<EOF
193 From: norm@example.com
194 To: phyl@example.com
195 cc:
196 Fcc: sent
197 Subject: test2
198 MIME-Version: 1.0
199 Content-Type: text/plain
200 EOF
201 check "`mhpath +drafts`/${sbackup}1" "$expected"
202
203 finish_test
204
205 exit ${failed:-0}