1#!/bin/sh
2######################################################
3#
4# Test prompter
5#
6######################################################
7
8
9. "$MH_TEST_COMMON"
10
11
12
13# check -help
14runandcheck "prompter -help" <<!
15Usage: prompter [switches] file
16  switches are:
17  -[no]prepend
18  -[no]rapid
19  -[no]body
20  -Version
21  -help
22!
23
24
25# check -version
26case `prompter -V` in
27  prompter\ --*) ;;
28  *            ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2
29                 failed=`expr ${failed:-0} + 1`;;
30esac
31
32# check unknown switch
33runandcheck 'prompter -nonexistent' <<!
34prompter: -nonexistent unknown
35!
36
37
38
39# check with no switches
40
41runandcheck 'prompter' <<!
42prompter: usage: prompter [switches] file
43!
44
45
46
47# check with file
48
49cat >$MH_TEST_DIR/prompter-file <<EOF
50Resent-From: sender@example.com
51Resent-To:
52Resent-cc:
53Resent-fcc:
54EOF
55
56printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n' | \
57	prompter $MH_TEST_DIR/prompter-file >/dev/null
58
59runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
60Resent-From: sender@example.com
61Resent-To: recipient@example.com
62Resent-cc: cc@example.com
63Resent-fcc: +outbox
64--------
65message body
66!
67
68
69
70# check -noprepend
71
72cat >$MH_TEST_DIR/prompter-file <<EOF
73Resent-From: sender@example.com
74Resent-To:
75Resent-cc:
76Resent-fcc:
77--------
78message body
79EOF
80
81printf 'recipient@example.com\ncc@example.com\n+outbox\nappendage\n' | \
82	prompter -noprepend $MH_TEST_DIR/prompter-file >/dev/null
83
84runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
85Resent-From: sender@example.com
86Resent-To: recipient@example.com
87Resent-cc: cc@example.com
88Resent-fcc: +outbox
89--------
90message body
91appendage
92!
93
94
95# check -prepend
96
97cat >$MH_TEST_DIR/prompter-file <<EOF
98Resent-From: sender@example.com
99Resent-To:
100Resent-cc:
101Resent-fcc:
102--------
103message body
104EOF
105
106printf 'recipient@example.com\ncc@example.com\n+outbox\nprependage\n' | \
107	prompter -noprepend -prepend $MH_TEST_DIR/prompter-file >/dev/null
108
109runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
110Resent-From: sender@example.com
111Resent-To: recipient@example.com
112Resent-cc: cc@example.com
113Resent-fcc: +outbox
114--------
115prependage
116message body
117!
118
119
120# check -rapid
121
122runandcheck "</dev/null prompter -rapid $MH_TEST_DIR/prompter-file" <<!
123Resent-From: sender@example.com
124Resent-To: recipient@example.com
125Resent-cc: cc@example.com
126Resent-fcc: +outbox
127--------Enter initial text
128--------
129!
130
131
132
133# check -norapid
134
135runandcheck "</dev/null prompter -rapid -norapid $MH_TEST_DIR/prompter-file" <<!
136Resent-From: sender@example.com
137Resent-To: recipient@example.com
138Resent-cc: cc@example.com
139Resent-fcc: +outbox
140--------Enter initial text
141prependage
142message body
143--------
144!
145
146
147
148# check -body.
149
150runandcheck "echo 'woot woot' | prompter -nobody -body $MH_TEST_DIR/prompter-file" <<!
151Resent-From: sender@example.com
152Resent-To: recipient@example.com
153Resent-cc: cc@example.com
154Resent-fcc: +outbox
155--------Enter initial text
156prependage
157message body
158--------
159!
160
161runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
162Resent-From: sender@example.com
163Resent-To: recipient@example.com
164Resent-cc: cc@example.com
165Resent-fcc: +outbox
166--------
167woot woot
168prependage
169message body
170!
171