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