1 Return-Path: <novalazy@gmail.com>
\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 77A7C429E39
\r
6 for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:52:29 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id bO3f1TJ0rT0H for <notmuch@notmuchmail.org>;
\r
17 Sat, 19 Jan 2013 16:52:27 -0800 (PST)
\r
18 Received: from mail-da0-f46.google.com (mail-da0-f46.google.com
\r
19 [209.85.210.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id E2E12429E28
\r
22 for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:52:11 -0800 (PST)
\r
23 Received: by mail-da0-f46.google.com with SMTP id p5so2154476dak.5
\r
24 for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:52:11 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
27 :references; bh=LrcVOKo2VI2PCjAz2TD8/4GlNTBMVK6h7UQdPVgM1TU=;
\r
28 b=VVzGWeKX19W1GfMlAGxIM3zW9EmB0UpPpW3pbf1+JapJPpRcw/fcwwiZz/sMUQFV5c
\r
29 685i/5ik3vkyEb8Wdz0qznnA/ypxEnQYdszha+hKterdQ2+V+D9OPqtSlkxU+/e2lnO5
\r
30 XQ4CKMMOpDpCkFHquVrp4gGWlIQneSoh63cyWBkGBlQ6+y6Q8BkiA9Bh5mGIz12KUb49
\r
31 VZ8JK+iT/Riv8prI1E5cIlBp72P+YbvhBQmCEp9Hznw/DYyugIyWSU+VsPL8P6JyUs9m
\r
32 UUSKc+5ht2NJnS47Adum3oCVQ+BpeRds+ckrX+joqZBJzV+UhYAsVsAtjVSIyIJAkGMs
\r
34 X-Received: by 10.68.233.201 with SMTP id ty9mr38218668pbc.14.1358643131057;
\r
35 Sat, 19 Jan 2013 16:52:11 -0800 (PST)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id c2sm6259934pay.34.2013.01.19.16.52.08
\r
39 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
40 Sat, 19 Jan 2013 16:52:10 -0800 (PST)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v3 20/20] test: add tests for insert
\r
44 Date: Sun, 20 Jan 2013 11:50:04 +1100
\r
45 Message-Id: <1358643004-14522-21-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.12.1
\r
47 In-Reply-To: <1358643004-14522-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1358643004-14522-1-git-send-email-novalazy@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sun, 20 Jan 2013 00:52:29 -0000
\r
63 Add tests for new 'insert' command.
\r
65 test/insert | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
66 test/notmuch-test | 1 +
\r
67 2 files changed, 107 insertions(+)
\r
68 create mode 100755 test/insert
\r
70 diff --git a/test/insert b/test/insert
\r
71 new file mode 100755
\r
72 index 0000000..a3b6283
\r
76 +#!/usr/bin/env bash
\r
77 +test_description='"notmuch insert"'
\r
80 +# Create directories and database before inserting.
\r
81 +mkdir -p "$MAIL_DIR"/{cur,new,tmp}
\r
82 +mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}
\r
83 +notmuch new > /dev/null
\r
85 +# We use generate_message to create the temporary message files.
\r
86 +# They happen to be in the mail directory already but that is okay
\r
87 +# since we do not call notmuch new hereafter.
\r
90 + generate_message \
\r
91 + "[subject]=\"insert-subject\"" \
\r
92 + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
\r
93 + "[body]=\"insert-message\""
\r
96 +test_begin_subtest "Insert message, copied exactly"
\r
98 +notmuch insert < "$gen_msg_filename"
\r
99 +cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
\r
100 +test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
\r
102 +test_begin_subtest "Insert message, default tags"
\r
103 +output=$(notmuch show --format=json "subject:insert-subject")
\r
105 + "id": "'"${gen_msg_id}"'",
\r
107 + "excluded": false,
\r
108 + "filename": "'"${cur_msg_filename}"'",
\r
109 + "timestamp": 946728000,
\r
110 + "date_relative": "2000-01-01",
\r
111 + "tags": ["inbox","unread"],
\r
113 + "Subject": "insert-subject",
\r
114 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
115 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
116 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
117 + "body": [{"id": 1,
\r
118 + "content-type": "text/plain",
\r
119 + "content": "insert-message\n"}]},
\r
121 +test_expect_equal_json "$output" "$expected"
\r
123 +test_begin_subtest "Insert message, duplicate message"
\r
124 +notmuch insert < "$gen_msg_filename"
\r
125 +output=$(notmuch search --output=files "subject:insert-subject" | wc -l)
\r
126 +test_expect_equal "$output" 2
\r
128 +test_begin_subtest "Insert message, add tag"
\r
130 +notmuch insert +custom < "$gen_msg_filename"
\r
131 +output=$(notmuch count tag:custom)
\r
132 +test_expect_equal "$output" "1"
\r
134 +test_begin_subtest "Insert message, add/remove tag"
\r
136 +notmuch insert +custom -unread < "$gen_msg_filename"
\r
137 +output=$(notmuch count tag:custom NOT tag:unread)
\r
138 +test_expect_equal "$output" "1"
\r
140 +test_begin_subtest "Insert message, folder"
\r
142 +notmuch insert --folder=Drafts < "$gen_msg_filename"
\r
143 +output=$(notmuch search --output=files folder:Drafts)
\r
144 +dirname=$(dirname "$output")
\r
145 +test_expect_equal "$dirname" "$MAIL_DIR/Drafts/cur"
\r
147 +test_begin_subtest "Insert message, folder and tags"
\r
149 +notmuch insert --folder=Drafts +draft -unread < "$gen_msg_filename"
\r
150 +output=$(notmuch count folder:Drafts tag:draft NOT tag:unread)
\r
151 +test_expect_equal "$output" "1"
\r
154 +test_expect_code 1 "Insert message, non-existent folder" \
\r
155 + "notmuch insert --folder=nonesuch < $gen_msg_filename"
\r
157 +test_begin_subtest "Insert message, create folder"
\r
159 +notmuch insert --folder=F --create-folder +folder < "$gen_msg_filename"
\r
160 +output=$(notmuch search --output=files folder:F tag:folder)
\r
161 +basename=$(basename "$output")
\r
162 +test_expect_equal_file "$gen_msg_filename" "$MAIL_DIR/F/cur/${basename}"
\r
164 +test_begin_subtest "Insert message, create subfolder"
\r
166 +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename"
\r
167 +output=$(notmuch search --output=files folder:F/G/H/I/J tag:folder)
\r
168 +basename=$(basename "$output")
\r
169 +test_expect_equal_file "$gen_msg_filename" "${MAIL_DIR}/F/G/H/I/J/cur/${basename}"
\r
171 +test_begin_subtest "Insert message, create existing subfolder"
\r
173 +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename"
\r
174 +output=$(notmuch count folder:F/G/H/I/J tag:folder)
\r
175 +test_expect_equal "$output" "2"
\r
178 +test_expect_code 1 "Insert message, create invalid subfolder" \
\r
179 + "notmuch insert --folder=../G --create-folder $gen_msg_filename"
\r
182 diff --git a/test/notmuch-test b/test/notmuch-test
\r
183 index ca9c3dc..6952f0a 100755
\r
184 --- a/test/notmuch-test
\r
185 +++ b/test/notmuch-test
\r
186 @@ -22,6 +22,7 @@ TESTS="
\r