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