File: test-whom

package info (click to toggle)
nmh 1.6-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,204 kB
  • ctags: 3,851
  • sloc: ansic: 48,922; sh: 16,422; makefile: 559; perl: 509; lex: 402; awk: 74
file content (123 lines) | stat: -rwxr-xr-x 2,912 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
######################################################
#
# Test whom
#
######################################################

# Not tested:
# -check, -client, -server, -port, -user, -sasl, -saslmech, -snoop, -tls, -notls

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname $0`/../..
    MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual

cd $MH_TEST_DIR

cat >$MH_TEST_DIR/Mail/draft <<'EOF'
From: Test1 <test1@example.com>
To: Some User <user@example.com>
Subject: Testing message 1
--------
This is a draft message.
EOF

# check -help
# Only look at first 10 lines because the rest depend on
# whether sasl support was configured in.
cat >$expected <<EOF
Usage: whom [switches] [file]
  switches are:
  -alias aliasfile
  -[no]check
  -draft
  -(draftf)older +folder
  -(draftm)essage msg
  -nodraftfolder
  -version
  -help
EOF

run_prog whom -help | head -10 >$actual 2>&1
check $expected $actual

# check -version
case `whom -v` in
  whom\ --*) ;;
  *       ) echo "$0: whom -v generated unexpected output" 1>&2
            failed=`expr ${failed:-0} + 1`;;
esac

# check with no options
run_test 'whom' '  -- Network Recipients --
  user at example.com'

# check -nocheck
run_test 'whom -check -nocheck' '  -- Network Recipients --
  user at example.com'

# check with file specified
run_test "whom $MH_TEST_DIR/Mail/draft" '  -- Network Recipients --
  user at example.com'

# check -draftmessage
run_test "whom -draftm draft" '  -- Network Recipients --
  user at example.com'

# check -draftfolder with -draftmessage
folder +drafts -create >/dev/null
folder +inbox -fast >/dev/null
cp $MH_TEST_DIR/Mail/draft $MH_TEST_DIR/Mail/drafts/1
run_test "whom -draftfolder +drafts -draftm 1" \
'  -- Network Recipients --
  user at example.com'

# check -draftfolder with current draftmessage
folder +drafts 1 >/dev/null
run_test "whom -draftfolder +drafts" \
'  -- Network Recipients --
  user at example.com'

# check -nodraftfolder
run_test 'whom -draftfolder +nonexistent -nodraftfolder' \
'  -- Network Recipients --
  user at example.com'

# check -draft, though I'm not sure that it's useful.  Note that it
# must appear after the file argument when run standalone.
run_test "whom $MH_TEST_DIR/Mail/drafts/1 -draft" \
'  -- Network Recipients --
  user at example.com'

# check -alias
rm -f $MH_TEST_DIR/Mail/draft
cat >$MH_TEST_DIR/Mail/draft <<'EOF'
From: Test1 <test1@example.com>
To: u
Subject: Testing message 1
--------
This is a draft message.
EOF

cat >$MH_TEST_DIR/Mail/nmhaliases <<'EOF'
u: user1@example.com
EOF
run_test 'whom -alias nmhaliases' '  -- Network Recipients --
  user1 at example.com'

# check -alias with nonexistent aliasfile
run_test 'whom -alias nonexistent' \
"whom: aliasing error in nonexistent - unable to read 'nonexistent'"


exit $failed