Rearranged test suite environment variables so that individual tests
[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 test -z "${MH_OBJ_DIR}"; then
8     srcdir=`dirname $0`/../..
9     MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test
15
16 runtest()
17 {
18         testoutput=$(${MH_LIB_DIR}/ap -format "%(mymbox{text})" "$1")
19
20         if [ -z "${testoutput}" ]; then
21                 echo "Test program did not return anything for $3"
22                 exit 1
23         fi
24
25         if [ "${testoutput}" -ne $2 ]; then
26                 echo "Did not get expected output for $3"
27                 exit 1
28         fi
29 }
30
31 user="$(id -un)"
32 host="$(hostname)"
33
34 runtest "${user}" 1 "Basic user test"
35 runtest "${user}@${host}" 1 "Basic user@host test"
36 runtest "nosuchuser@nosuchhost.blah" 0 "Basic non-matching test"
37
38 myname="Random User <random@user.something.com>"
39
40 echo "Local-Mailbox: ${myname}" >> ${MH}
41
42 runtest "${myname}" 1 "Local-Mailbox test"
43 runtest "${user}@${host}" 0 "Local-mailbox overriding user@host test"
44
45 exit 0