]> git.notmuchmail.org Git - notmuch/blob - test/t0004-thread-naming.sh
test: Fix test suite to integrate with our non-recursive Makefile system.
[notmuch] / test / t0004-thread-naming.sh
1 #!/bin/bash
2 test_description="naming of threads with changing subject"
3 . ./test-lib.sh
4 test_expect_success 'Generate some messages' '
5 add_message "[subject]=\"thread-naming: Initial thread subject\"" \
6             "[date]=\"Fri, 05 Jan 2001 15:43:56 -0000\"" &&
7 first=${gen_msg_cnt} &&
8 parent=${gen_msg_id} &&
9 add_message "[subject]=\"thread-naming: Older changed subject\"" \
10             "[date]=\"Sat, 06 Jan 2001 15:43:56 -0000\"" \
11             "[in-reply-to]=\<$parent\>" &&
12 add_message "[subject]=\"thread-naming: Newer changed subject\"" \
13             "[date]=\"Sun, 07 Jan 2001 15:43:56 -0000\"" \
14             "[in-reply-to]=\<$parent\>" &&
15 add_message "[subject]=\"thread-naming: Final thread subject\"" \
16             "[date]=\"Mon, 08 Jan 2001 15:43:56 -0000\"" \
17             "[in-reply-to]=\<$parent\>" &&
18 final=${gen_msg_id}
19
20 '
21 test_expect_success "Initial thread name (oldest-first search)" '
22 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
23 pass_if_equal "$output" "thread:XXX   2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
24
25 '
26 test_expect_success "Initial thread name (newest-first search)" '
27 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
28 pass_if_equal "$output" "thread:XXX   2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
29
30 # Remove oldest and newest messages from search results
31 $NOTMUCH tag -inbox id:$parent or id:$final
32
33 '
34 test_expect_success "Changed thread name (oldest-first search)" '
35 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
36 pass_if_equal "$output" "thread:XXX   2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
37
38 '
39 test_expect_success "Changed thread name (newest-first search)" '
40 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
41 pass_if_equal "$output" "thread:XXX   2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
42
43 '
44 test_expect_success "Ignore added reply prefix (Re:)" '
45 add_message "[subject]=\"Re: thread-naming: Initial thread subject\"" \
46             "[date]=\"Tue, 09 Jan 2001 15:43:45 -0000\"" \
47             "[in-reply-to]=\<$parent\>" &&
48 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
49 pass_if_equal "$output" "thread:XXX   2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
50
51 '
52 test_expect_success "Ignore added reply prefix (Aw:)" '
53 add_message "[subject]=\"Aw: thread-naming: Initial thread subject\"" \
54             "[date]=\"Wed, 10 Jan 2001 15:43:45 -0000\"" \
55             "[in-reply-to]=\<$parent\>" &&
56 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
57 pass_if_equal "$output" "thread:XXX   2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
58
59 '
60 test_expect_success "Ignore added reply prefix (Vs:)" '
61 add_message "[subject]=\"Vs: thread-naming: Initial thread subject\"" \
62             "[date]=\"Thu, 11 Jan 2001 15:43:45 -0000\"" \
63             "[in-reply-to]=\<$parent\>" &&
64 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
65 pass_if_equal "$output" "thread:XXX   2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
66
67 '
68 test_expect_success "Ignore added reply prefix (Sv:)" '
69 add_message "[subject]=\"Sv: thread-naming: Initial thread subject\"" \
70             "[date]=\"Fri, 12 Jan 2001 15:43:45 -0000\"" \
71             "[in-reply-to]=\<$parent\>" &&
72 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
73 pass_if_equal "$output" "thread:XXX   2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
74
75 '
76 test_expect_success "Test order of messages in \"notmuch show\"" '
77 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize) &&
78 pass_if_equal "$output" "\fmessage{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
79 \fheader{
80 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
81 Subject: thread-naming: Initial thread subject
82 From: Notmuch Test Suite <test_suite@notmuchmail.org>
83 To: Notmuch Test Suite <test_suite@notmuchmail.org>
84 Date: Fri, 05 Jan 2001 15:43:56 -0000
85 \fheader}
86 \fbody{
87 \fpart{ ID: 1, Content-type: text/plain
88 This is just a test message (#$first)
89 \fpart}
90 \fbody}
91 \fmessage}
92 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
93 \fheader{
94 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
95 Subject: thread-naming: Older changed subject
96 From: Notmuch Test Suite <test_suite@notmuchmail.org>
97 To: Notmuch Test Suite <test_suite@notmuchmail.org>
98 Date: Sat, 06 Jan 2001 15:43:56 -0000
99 \fheader}
100 \fbody{
101 \fpart{ ID: 1, Content-type: text/plain
102 This is just a test message (#$((first + 1)))
103 \fpart}
104 \fbody}
105 \fmessage}
106 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
107 \fheader{
108 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
109 Subject: thread-naming: Newer changed subject
110 From: Notmuch Test Suite <test_suite@notmuchmail.org>
111 To: Notmuch Test Suite <test_suite@notmuchmail.org>
112 Date: Sun, 07 Jan 2001 15:43:56 -0000
113 \fheader}
114 \fbody{
115 \fpart{ ID: 1, Content-type: text/plain
116 This is just a test message (#$((first + 2)))
117 \fpart}
118 \fbody}
119 \fmessage}
120 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
121 \fheader{
122 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
123 Subject: thread-naming: Final thread subject
124 From: Notmuch Test Suite <test_suite@notmuchmail.org>
125 To: Notmuch Test Suite <test_suite@notmuchmail.org>
126 Date: Mon, 08 Jan 2001 15:43:56 -0000
127 \fheader}
128 \fbody{
129 \fpart{ ID: 1, Content-type: text/plain
130 This is just a test message (#$((first + 3)))
131 \fpart}
132 \fbody}
133 \fmessage}
134 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
135 \fheader{
136 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
137 Subject: Re: thread-naming: Initial thread subject
138 From: Notmuch Test Suite <test_suite@notmuchmail.org>
139 To: Notmuch Test Suite <test_suite@notmuchmail.org>
140 Date: Tue, 09 Jan 2001 15:43:45 -0000
141 \fheader}
142 \fbody{
143 \fpart{ ID: 1, Content-type: text/plain
144 This is just a test message (#$((first + 4)))
145 \fpart}
146 \fbody}
147 \fmessage}
148 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
149 \fheader{
150 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
151 Subject: Aw: thread-naming: Initial thread subject
152 From: Notmuch Test Suite <test_suite@notmuchmail.org>
153 To: Notmuch Test Suite <test_suite@notmuchmail.org>
154 Date: Wed, 10 Jan 2001 15:43:45 -0000
155 \fheader}
156 \fbody{
157 \fpart{ ID: 1, Content-type: text/plain
158 This is just a test message (#$((first + 5)))
159 \fpart}
160 \fbody}
161 \fmessage}
162 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
163 \fheader{
164 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
165 Subject: Vs: thread-naming: Initial thread subject
166 From: Notmuch Test Suite <test_suite@notmuchmail.org>
167 To: Notmuch Test Suite <test_suite@notmuchmail.org>
168 Date: Thu, 11 Jan 2001 15:43:45 -0000
169 \fheader}
170 \fbody{
171 \fpart{ ID: 1, Content-type: text/plain
172 This is just a test message (#$((first + 6)))
173 \fpart}
174 \fbody}
175 \fmessage}
176 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
177 \fheader{
178 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
179 Subject: Sv: thread-naming: Initial thread subject
180 From: Notmuch Test Suite <test_suite@notmuchmail.org>
181 To: Notmuch Test Suite <test_suite@notmuchmail.org>
182 Date: Fri, 12 Jan 2001 15:43:45 -0000
183 \fheader}
184 \fbody{
185 \fpart{ ID: 1, Content-type: text/plain
186 This is just a test message (#$((first + 7)))
187 \fpart}
188 \fbody}
189 \fmessage}"
190 '
191 test_done