]> git.notmuchmail.org Git - notmuch/blob - test/thread-naming
test: add sanity check for dump --format=batch-tag.
[notmuch] / test / thread-naming
1 #!/usr/bin/env bash
2 test_description="naming of threads with changing subject"
3 . ./test-lib.sh
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 'Test order of messages in "notmuch show"'
67 output=$(notmuch show thread-naming | notmuch_show_sanitize)
68 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)
69 \fheader{
70 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
71 Subject: thread-naming: Initial thread subject
72 From: Notmuch Test Suite <test_suite@notmuchmail.org>
73 To: Notmuch Test Suite <test_suite@notmuchmail.org>
74 Date: Fri, 05 Jan 2001 15:43:56 +0000
75 \fheader}
76 \fbody{
77 \fpart{ ID: 1, Content-type: text/plain
78 This is just a test message (#$first)
79 \fpart}
80 \fbody}
81 \fmessage}
82 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
83 \fheader{
84 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
85 Subject: thread-naming: Older changed subject
86 From: Notmuch Test Suite <test_suite@notmuchmail.org>
87 To: Notmuch Test Suite <test_suite@notmuchmail.org>
88 Date: Sat, 06 Jan 2001 15:43:56 +0000
89 \fheader}
90 \fbody{
91 \fpart{ ID: 1, Content-type: text/plain
92 This is just a test message (#$((first + 1)))
93 \fpart}
94 \fbody}
95 \fmessage}
96 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
97 \fheader{
98 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
99 Subject: thread-naming: Newer changed subject
100 From: Notmuch Test Suite <test_suite@notmuchmail.org>
101 To: Notmuch Test Suite <test_suite@notmuchmail.org>
102 Date: Sun, 07 Jan 2001 15:43:56 +0000
103 \fheader}
104 \fbody{
105 \fpart{ ID: 1, Content-type: text/plain
106 This is just a test message (#$((first + 2)))
107 \fpart}
108 \fbody}
109 \fmessage}
110 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
111 \fheader{
112 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
113 Subject: thread-naming: Final thread subject
114 From: Notmuch Test Suite <test_suite@notmuchmail.org>
115 To: Notmuch Test Suite <test_suite@notmuchmail.org>
116 Date: Mon, 08 Jan 2001 15:43:56 +0000
117 \fheader}
118 \fbody{
119 \fpart{ ID: 1, Content-type: text/plain
120 This is just a test message (#$((first + 3)))
121 \fpart}
122 \fbody}
123 \fmessage}
124 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
125 \fheader{
126 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
127 Subject: Re: thread-naming: Initial thread subject
128 From: Notmuch Test Suite <test_suite@notmuchmail.org>
129 To: Notmuch Test Suite <test_suite@notmuchmail.org>
130 Date: Tue, 09 Jan 2001 15:43:45 +0000
131 \fheader}
132 \fbody{
133 \fpart{ ID: 1, Content-type: text/plain
134 This is just a test message (#$((first + 4)))
135 \fpart}
136 \fbody}
137 \fmessage}
138 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
139 \fheader{
140 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
141 Subject: Aw: thread-naming: Initial thread subject
142 From: Notmuch Test Suite <test_suite@notmuchmail.org>
143 To: Notmuch Test Suite <test_suite@notmuchmail.org>
144 Date: Wed, 10 Jan 2001 15:43:45 +0000
145 \fheader}
146 \fbody{
147 \fpart{ ID: 1, Content-type: text/plain
148 This is just a test message (#$((first + 5)))
149 \fpart}
150 \fbody}
151 \fmessage}
152 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
153 \fheader{
154 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
155 Subject: Vs: thread-naming: Initial thread subject
156 From: Notmuch Test Suite <test_suite@notmuchmail.org>
157 To: Notmuch Test Suite <test_suite@notmuchmail.org>
158 Date: Thu, 11 Jan 2001 15:43:45 +0000
159 \fheader}
160 \fbody{
161 \fpart{ ID: 1, Content-type: text/plain
162 This is just a test message (#$((first + 6)))
163 \fpart}
164 \fbody}
165 \fmessage}
166 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
167 \fheader{
168 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
169 Subject: Sv: thread-naming: Initial thread subject
170 From: Notmuch Test Suite <test_suite@notmuchmail.org>
171 To: Notmuch Test Suite <test_suite@notmuchmail.org>
172 Date: Fri, 12 Jan 2001 15:43:45 +0000
173 \fheader}
174 \fbody{
175 \fpart{ ID: 1, Content-type: text/plain
176 This is just a test message (#$((first + 7)))
177 \fpart}
178 \fbody}
179 \fmessage}"
180 test_done