[PATCH] Have notmuch count default to showing the total.
[notmuch-archives.git] / c6 / 55121a26371d77ef4aea86a3386585f1a0ebab
1 Return-Path: <sojkam1@fel.cvut.cz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id A1FFD40496E\r
6         for <notmuch@notmuchmail.org>; Thu, 18 Mar 2010 08:41:00 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.271\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.271 tagged_above=-999 required=5 tests=[AWL=0.328,\r
12         BAYES_00=-2.599] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id Ik2DhMgBf7oR for <notmuch@notmuchmail.org>;\r
16         Thu, 18 Mar 2010 08:40:59 -0700 (PDT)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id B6AF8404966\r
19         for <notmuch@notmuchmail.org>; Thu, 18 Mar 2010 08:40:55 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 2AAA819F33D7;\r
22         Thu, 18 Mar 2010 16:40:55 +0100 (CET)\r
23 X-Virus-Scanned: IMAP AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id rY-0vUw0GZgT; Thu, 18 Mar 2010 16:40:52 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id C99A819F340B;\r
30         Thu, 18 Mar 2010 16:40:51 +0100 (CET)\r
31 Received: from steelpick.localdomain (k335-30.felk.cvut.cz [147.32.86.30])\r
32         (Authenticated sender: sojkam1)\r
33         by imap.feld.cvut.cz (Postfix) with ESMTPSA id B1D3AFA004;\r
34         Thu, 18 Mar 2010 16:40:51 +0100 (CET)\r
35 Received: from wsh by steelpick.localdomain with local (Exim 4.71)\r
36         (envelope-from <sojkam1@fel.cvut.cz>)\r
37         id 1NsHq7-0005Ho-F3; Thu, 18 Mar 2010 16:40:51 +0100\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
39 To: notmuch@notmuchmail.org\r
40 Date: Thu, 18 Mar 2010 16:39:40 +0100\r
41 Message-Id: <1268926780-20045-5-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-Mailer: git-send-email 1.7.0\r
43 In-Reply-To: <1268926780-20045-1-git-send-email-sojkam1@fel.cvut.cz>\r
44 References: <1268926780-20045-1-git-send-email-sojkam1@fel.cvut.cz>\r
45 Subject: [notmuch] [PATCH 4/4] Tests for maildir-based mailstore\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Thu, 18 Mar 2010 15:41:01 -0000\r
59 \r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
61 ---\r
62  test/t0006-maildir.sh |  113 +++++++++++++++++++++++++++++++++++++++++++++++++\r
63  test/test-lib.sh      |    7 ++-\r
64  2 files changed, 118 insertions(+), 2 deletions(-)\r
65  create mode 100755 test/t0006-maildir.sh\r
66 \r
67 diff --git a/test/t0006-maildir.sh b/test/t0006-maildir.sh\r
68 new file mode 100755\r
69 index 0000000..e584908\r
70 --- /dev/null\r
71 +++ b/test/t0006-maildir.sh\r
72 @@ -0,0 +1,113 @@\r
73 +#!/bin/bash\r
74 +\r
75 +test_description="Test maildir mailstore"\r
76 +\r
77 +. ./test-lib.sh\r
78 +\r
79 +filter_output() {\r
80 +    grep -v -E -e "$NOTMUCH_IGNORED_OUTPUT_REGEXP" | sed -e "$NOTMUCH_THREAD_ID_SQUELCH"\r
81 +}\r
82 +\r
83 +filter_show() {\r
84 +    sed -e 's/, /,\n/g'|sed -e '/^"filename"/ s/:2,[A-Z]*//' -e '/^"tags"/d'\r
85 +}\r
86 +\r
87 +cat >> "$NOTMUCH_CONFIG" <<EOF\r
88 +[mailstore]\r
89 +type=maildir\r
90 +EOF\r
91 +\r
92 +test_expect_success "No new mail" '\r
93 +execute_expecting new "No new mail."\r
94 +'\r
95 +cat > expected <<EOF\r
96 +Added 1 new message to the database.\r
97 +EOF\r
98 +test_expect_success "Add a message, no flags" '\r
99 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&\r
100 +notmuch new | filter_output > actual &&\r
101 +test_cmp expected actual\r
102 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"\r
103 +'\r
104 +cat > expected <<EOF\r
105 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)\r
106 +EOF\r
107 +test_expect_success 'Search for the message' '\r
108 +notmuch search tag:inbox and tag:unread | filter_output > actual &&\r
109 +test_cmp expected actual\r
110 +'\r
111 +cat > expected <<EOF\r
112 +No new mail. Detected 1 file rename.\r
113 +EOF\r
114 +test_expect_success 'Add seen flag' '\r
115 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&\r
116 +increment_mtime "$(dirname "${gen_msg_filename}")" &&\r
117 +notmuch new | filter_output > actual &&\r
118 +test_cmp expected actual\r
119 +'\r
120 +cat > expected <<EOF\r
121 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)\r
122 +EOF\r
123 +test_expect_success 'Check that tags were updated' '\r
124 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&\r
125 +test_cmp expected actual\r
126 +'\r
127 +cat > expected <<EOF\r
128 +Added 1 new message to the database.\r
129 +EOF\r
130 +test_expect_success "Add a seen message" '\r
131 +generate_message [subject]="\"test message2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&\r
132 +notmuch new | filter_output > actual &&\r
133 +test_cmp expected actual\r
134 +'\r
135 +cat > expected <<EOF\r
136 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)\r
137 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message2 (inbox)\r
138 +EOF\r
139 +test_expect_success 'Check that the seen message is not tagged unread' '\r
140 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&\r
141 +test_cmp expected actual\r
142 +'\r
143 +test_expect_success 'Tag the seen messages as replied' '\r
144 +notmuch tag +replied -inbox tag:inbox and not tag:unread\r
145 +'\r
146 +\r
147 +cat > expected <<EOF\r
148 +msg-001:2,RS\r
149 +msg-002:2,RS\r
150 +EOF\r
151 +test_expect_success 'Check that R flag was added (rename)' '\r
152 +ls -1 "${MAIL_DIR}" > actual &&\r
153 +test_cmp expected actual\r
154 +'\r
155 +echo -n '[[[{"id": "msg-001@notmuch-test-suite",\r
156 +"match": true,\r
157 +"filename": "/home/wsh/src/notmuch/test/trash directory.t0006-maildir/mail/msg-001",\r
158 +"headers": {"Subject": "test message",\r
159 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
160 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
161 +"Cc": "",\r
162 +"Bcc": "",\r
163 +"Date": "Sat,\r
164 +01 Jan 2000 12:00:00 -0000"},\r
165 +"body": [{"id": 1,\r
166 +"content-type": "text/plain",\r
167 +"content": "This is just a test message at /home/wsh/src/notmuch/test/trash directory.t0006-maildir/mail/msg-001:2,\n"}]},\r
168 +[]]]]' > show-expected\r
169 +\r
170 +test_expect_success 'Renamed message can be shown without running notmuch new' '\r
171 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&\r
172 +test_cmp show-expected show-actual\r
173 +'\r
174 +\r
175 +test_expect_success 'Test that we can reply to the renamed message' '\r
176 +notmuch reply id:msg-001@notmuch-test-suite\r
177 +'\r
178 +\r
179 +echo "No new mail." > expected\r
180 +test_expect_success 'No rename should be detected by notmuch new' '\r
181 +increment_mtime "$(dirname "${gen_msg_filename}")" &&\r
182 +notmuch new > actual &&\r
183 +test_cmp expected actual\r
184 +'\r
185 +test_done\r
186 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
187 index 5417fe7..917631b 100755\r
188 --- a/test/test-lib.sh\r
189 +++ b/test/test-lib.sh\r
190 @@ -257,8 +257,11 @@ generate_message ()\r
191      local additional_headers\r
192  \r
193      gen_msg_cnt=$((gen_msg_cnt + 1))\r
194 -    gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)\r
195 -    gen_msg_id="${gen_msg_name}@notmuch-test-suite"\r
196 +    if [ -z "${template[filename]}" ]; then\r
197 +       template[filename]="msg-$(printf "%03d" $gen_msg_cnt)"\r
198 +    fi\r
199 +    gen_msg_name=${template[filename]}\r
200 +    gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"\r
201  \r
202      if [ -z "${template[dir]}" ]; then\r
203         gen_msg_filename="${MAIL_DIR}/$gen_msg_name"\r
204 -- \r
205 1.7.0\r
206 \r