82f08792c94883384ac94a8d5a20e2558a08a9c4
[mmh] / test / format / test-mymbox
1 #!/bin/sh
2 #
3 # Test that the %(mymbox) function correctly determines whether or not
4 # a particular email address is "mine" or not
5 #
6
7 if [ -z "${MH_TEST_COMMON}" ]; then
8         echo "MH_TEST_COMMON not set; try running via 'make check'"
9 fi
10
11 . ${MH_TEST_COMMON}
12
13 setup_test
14
15 runtest()
16 {
17         testoutput=$(${MH_LIB_DIR}/ap -format "%(mymbox{text})" "$1")
18
19         if [ -z "${testoutput}" ]; then
20                 echo "Test program did not return anything for $3"
21                 exit 1
22         fi
23
24         if [ "${testoutput}" -ne $2 ]; then
25                 echo "Did not get expected output for $3"
26                 exit 1
27         fi
28 }
29
30 user="$(id -un)"
31 host="$(hostname)"
32
33 runtest "${user}" 1 "Basic user test"
34 runtest "${user}@${host}" 1 "Basic user@host test"
35 runtest "nosuchuser@nosuchhost.blah" 0 "Basic non-matching test"
36
37 myname="Random User <random@user.something.com>"
38
39 echo "Local-Mailbox: ${myname}" >> ${MH}
40
41 runtest "${myname}" 1 "Local-Mailbox test"
42 runtest "${user}@${host}" 0 "Local-mailbox overriding user@host test"
43
44 exit 0