Adjusted tests/new/test-basic to mmh.
[mmh] / test / tests / new / test-basic
1 #!/bin/sh
2
3 # TODO: Move to a common file tests can source; need more framework...
4 failed=0
5 check() {
6     diff -u $expected $actual
7     if [ $? -ne 0 ]; then
8         failed=$((failed + 1))
9     fi
10 }
11
12 folders=$MH_TEST_DIR/Mail/.folders
13
14 expected=$MH_TEST_DIR/$$.expected
15 actual=$MH_TEST_DIR/$$.actual
16
17 # make second folder
18 cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo1
19 cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo2
20 # but only list inbox and foo2 in .folders, and sorted differently
21 cat > $folders <<EOF
22 inbox
23 foo2
24 EOF
25
26 # test with no desired messages
27 cat > $expected <<EOF
28  total      0.
29 EOF
30 new aseq > $actual 2>&1
31 check
32 new -folders $folders aseq > $actual 2>&1
33 check
34
35 # test fnext/fprev with no desired messages
36 cat /dev/null > $expected
37 fnext aseq > $actual 2>&1
38 check
39 fprev aseq > $actual 2>&1
40 check
41
42 # add 1 desired message in each folder
43 echo 'aseq: 1' > $MH_TEST_DIR/Mail/inbox/.mh_sequences
44 echo 'aseq: 1' > $MH_TEST_DIR/Mail/foo1/.mh_sequences
45 echo 'aseq: 1' > $MH_TEST_DIR/Mail/foo2/.mh_sequences
46
47 # test with all folders
48 cat > $expected <<EOF
49 foo1       1.  1
50 foo2       1.  1
51 inbox      1.* 1
52  total      3.
53 EOF
54 new aseq > $actual 2>&1
55 check
56
57 # test with .folders
58 cat > $expected <<EOF
59 inbox      1.* 1
60 foo2       1.  1
61  total      2.
62 EOF
63 new -folders $folders aseq > $actual 2>&1
64 check
65
66 # add 2 desired messages to another sequence in each folder
67 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/inbox/.mh_sequences
68 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/foo1/.mh_sequences
69 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/foo2/.mh_sequences
70
71 # test listing aseq and bseq
72 cat > $expected <<EOF
73 foo1       3.  1 3-4
74 foo2       3.  1 3-4
75 inbox      3.* 1 3-4
76  total      9.
77 EOF
78 new aseq bseq > $actual 2>&1
79 check
80
81 # set aseq bseq as unseen
82 echo 'Unseen-Sequence: aseq bseq' >>"$MMH/profile"
83 new > $actual 2>&1
84 check
85
86 # test unseen
87 cat > $expected <<EOF
88
89 3 aseq bseq messages in foo1
90    1  2006-09-29 00:00  Test1              Testing message 1
91    3  2006-09-29 00:00  Test3              Testing message 3
92    4  2006-09-29 00:00  Test4              Testing message 4
93
94 3 aseq bseq messages in foo2
95    1  2006-09-29 00:00  Test1              Testing message 1
96    3  2006-09-29 00:00  Test3              Testing message 3
97    4  2006-09-29 00:00  Test4              Testing message 4
98
99 3 aseq bseq messages in inbox (*: current folder)
100    1  2006-09-29 00:00  Test1              Testing message 1
101    3  2006-09-29 00:00  Test3              Testing message 3
102    4  2006-09-29 00:00  Test4              Testing message 4
103 EOF
104 unseen > $actual 2>&1
105 check
106
107 # test fnext with the current folder not in the list
108 echo 'Current-Folder: foo1' >"$MMH/context"
109 echo 'inbox  1 3-4' > $expected
110 fnext -folders $folders > $actual 2>&1
111 check
112
113 # test fprev with the current folder not in the list
114 echo 'Current-Folder: foo1' >"$MMH/context"
115 echo 'inbox  1 3-4' > $expected
116 fprev -folders $folders > $actual 2>&1
117 check
118
119 # test fnext with current folder in the middle of the list
120 echo 'Current-Folder: foo2' >"$MMH/context"
121 echo 'inbox  1 3-4' > $expected
122 fnext > $actual 2>&1
123 check
124
125 # test fprev with current folder in the middle of the list
126 echo 'Current-Folder: foo2' >"$MMH/context"
127 echo 'foo1  1 3-4' > $expected
128 fprev > $actual 2>&1
129 check
130
131 # test fprev with current folder at the beginning of the list
132 echo 'Current-Folder: foo1' >"$MMH/context"
133 echo 'inbox  1 3-4' > $expected
134 fprev > $actual 2>&1
135 check
136
137 # test fnext with current folder at the end of the list
138 echo 'Current-Folder: inbox' >"$MMH/context"
139 echo 'foo1  1 3-4' > $expected
140 fnext > $actual 2>&1
141 check
142
143 # test fnext with no current folder
144 rm "$MMH/context"
145 echo 'foo1  1 3-4' > $expected
146 fnext > $actual 2>&1
147 check
148
149 # test fnext with only one folder in the list
150 cat > $folders <<EOF
151 inbox
152 EOF
153 echo 'inbox  1 3-4' > $expected
154 fnext -folders $folders > $actual 2>&1
155 check
156
157 exit $failed