]> diplodocus.org Git - nmh/blob - test/whom/test-whom
Update XOAUTH2 documentation.
[nmh] / test / whom / test-whom
1 #!/bin/sh
2 ######################################################
3 #
4 # Test whom
5 #
6 ######################################################
7
8 # Not tested:
9 # -check, -client, -server, -port, -user, -sasl, -saslmech, -snoop, -tls, -notls
10
11 set -e
12
13 if test -z "${MH_OBJ_DIR}"; then
14 srcdir=`dirname $0`/../..
15 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
16 fi
17
18 . "$MH_OBJ_DIR/test/common.sh"
19
20 setup_test
21
22 check_exit '-eq 1' whom -
23
24 expected=$MH_TEST_DIR/$$.expected
25 actual=$MH_TEST_DIR/$$.actual
26
27 cd $MH_TEST_DIR
28
29 cat >$MH_TEST_DIR/Mail/draft <<'EOF'
30 From: Test1 <test1@example.com>
31 To: Some User <user@example.com>
32 Subject: Testing message 1
33 --------
34 This is a draft message.
35 EOF
36
37 # check -help
38 start_test "-help"
39 # Only look at first 10 lines because the rest depend on
40 # whether sasl support was configured in.
41 cat >$expected <<EOF
42 Usage: whom [switches] [file]
43 switches are:
44 -alias aliasfile
45 -[no]check
46 -draft
47 -(draftf)older +folder
48 -(draftm)essage msg
49 -nodraftfolder
50 -version
51 -help
52 EOF
53
54 run_prog whom -help 2>&1 | head -10 >$actual
55 check $expected $actual
56
57 # check -version
58 start_test "-version"
59 case `whom -v` in
60 whom\ --*) ;;
61 * ) echo "$0: whom -v generated unexpected output" 1>&2
62 failed=`expr ${failed:-0} + 1`;;
63 esac
64
65 # check with no options
66 start_test "with no options"
67 run_test 'whom' ' -- Network Recipients --
68 user at example.com'
69
70 # check -nocheck
71 start_test "-nocheck"
72 run_test 'whom -check -nocheck' ' -- Network Recipients --
73 user at example.com'
74
75 # check with file specified
76 start_test "with file specified"
77 run_test "whom $MH_TEST_DIR/Mail/draft" ' -- Network Recipients --
78 user at example.com'
79
80 # check -draftmessage
81 start_test "-draftmessage"
82 run_test "whom -draftm draft" ' -- Network Recipients --
83 user at example.com'
84
85 # check -draftfolder with -draftmessage
86 start_test "-draftfolder with -draftmessage"
87 folder +drafts -create >/dev/null
88 folder +inbox -fast >/dev/null
89 cp $MH_TEST_DIR/Mail/draft $MH_TEST_DIR/Mail/drafts/1
90 run_test "whom -draftfolder +drafts -draftm 1" \
91 ' -- Network Recipients --
92 user at example.com'
93
94 # check -draftfolder with current draftmessage
95 start_test "-draftfolder with current draftmessage"
96 folder +drafts 1 >/dev/null
97 run_test "whom -draftfolder +drafts" \
98 ' -- Network Recipients --
99 user at example.com'
100
101 # check -nodraftfolder
102 start_test "-nodraftfolder"
103 run_test 'whom -draftfolder +nonexistent -nodraftfolder' \
104 ' -- Network Recipients --
105 user at example.com'
106
107 # check -draft, though I'm not sure that it's useful. Note that it
108 start_test "-draft, though I'm not sure that it's useful. Note that it"
109 # must appear after the file argument when run standalone.
110 run_test "whom $MH_TEST_DIR/Mail/drafts/1 -draft" \
111 ' -- Network Recipients --
112 user at example.com'
113
114 # check -alias
115 start_test "-alias"
116 rm -f $MH_TEST_DIR/Mail/draft
117 cat >$MH_TEST_DIR/Mail/draft <<'EOF'
118 From: Test1 <test1@example.com>
119 To: u
120 Subject: Testing message 1
121 --------
122 This is a draft message.
123 EOF
124
125 cat >$MH_TEST_DIR/Mail/nmhaliases <<'EOF'
126 u: user1@example.com
127 EOF
128 run_test 'whom -alias nmhaliases' ' -- Network Recipients --
129 user1 at example.com'
130
131 # check -alias with nonexistent aliasfile
132 start_test "-alias with nonexistent aliasfile"
133 run_test 'whom -alias nonexistent' \
134 "whom: aliasing error in nonexistent - unable to read 'nonexistent'"
135
136
137 finish_test
138 exit $failed