[PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / cf / 28363ceb2e4e9923df85e603e1ab7776df3ae4
1 Return-Path: <jani@nikula.org>\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 07626429E3F\r
6         for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 13:25:34 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[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 XlAjso0BeDku for <notmuch@notmuchmail.org>;\r
17         Fri,  4 Nov 2011 13:25:32 -0700 (PDT)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (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 9EFB3429E26\r
22         for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 13:25:32 -0700 (PDT)\r
23 Received: by mail-fx0-f53.google.com with SMTP id n15so52582faa.26\r
24         for <notmuch@notmuchmail.org>; Fri, 04 Nov 2011 13:25:32 -0700 (PDT)\r
25 Received: by 10.223.17.3 with SMTP id q3mr26424998faa.28.1320438332166;\r
26         Fri, 04 Nov 2011 13:25:32 -0700 (PDT)\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
28         [80.220.92.23])\r
29         by mx.google.com with ESMTPS id k26sm18321808fab.8.2011.11.04.13.25.30\r
30         (version=SSLv3 cipher=OTHER); Fri, 04 Nov 2011 13:25:31 -0700 (PDT)\r
31 From: Jani Nikula <jani@nikula.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v3 6/7] test: add tests for notmuch search --first and\r
34         --maxitems\r
35 Date: Fri,  4 Nov 2011 22:25:14 +0200\r
36 Message-Id:\r
37  <afb4948b9921a3219a8199e64be9e5d3c88749c4.1320349030.git.jani@nikula.org>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <cover.1320349030.git.jani@nikula.org>\r
40 References: <cover.1320349030.git.jani@nikula.org>\r
41 In-Reply-To: <cover.1320349030.git.jani@nikula.org>\r
42 References: <cover.1320349030.git.jani@nikula.org>\r
43 Cc: amdragon@mit.edu\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Fri, 04 Nov 2011 20:25:34 -0000\r
57 \r
58 Signed-off-by: Jani Nikula <jani@nikula.org>\r
59 ---\r
60  test/notmuch-test    |    1 +\r
61  test/search-limiting |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
62  2 files changed, 72 insertions(+), 0 deletions(-)\r
63  create mode 100755 test/search-limiting\r
64 \r
65 diff --git a/test/notmuch-test b/test/notmuch-test\r
66 index 587adb5..435b469 100755\r
67 --- a/test/notmuch-test\r
68 +++ b/test/notmuch-test\r
69 @@ -25,6 +25,7 @@ TESTS="\r
70    search-by-folder\r
71    search-position-overlap-bug\r
72    search-insufficient-from-quoting\r
73 +  search-limiting\r
74    json\r
75    multipart\r
76    thread-naming\r
77 diff --git a/test/search-limiting b/test/search-limiting\r
78 new file mode 100755\r
79 index 0000000..45cc0a9\r
80 --- /dev/null\r
81 +++ b/test/search-limiting\r
82 @@ -0,0 +1,71 @@\r
83 +#!/usr/bin/env bash\r
84 +test_description='"notmuch search" --first and --maxitems parameters'\r
85 +. ./test-lib.sh\r
86 +\r
87 +add_email_corpus\r
88 +\r
89 +for outp in messages threads; do\r
90 +    test_begin_subtest "${outp}: maxitems does the right thing"\r
91 +    notmuch search --output=${outp} "*" | head -n 20 >expected\r
92 +    notmuch search --output=${outp} --maxitems=20 "*" >output\r
93 +    test_expect_equal_file expected output\r
94 +\r
95 +    test_begin_subtest "${outp}: concatenation of limited searches"\r
96 +    notmuch search --output=${outp} "*" | head -n 20 >expected\r
97 +    notmuch search --output=${outp} --maxitems=10 "*" >output\r
98 +    notmuch search --output=${outp} --maxitems=10 --first=10 "*" >>output\r
99 +    test_expect_equal_file expected output\r
100 +\r
101 +    test_begin_subtest "${outp}: maxitems larger than result set"\r
102 +    N=`notmuch count --output=${outp} "*"`\r
103 +    notmuch search --output=${outp} "*" >expected\r
104 +    notmuch search --output=${outp} --maxitems=$((1 + ${N})) "*" >output\r
105 +    test_expect_equal_file expected output\r
106 +\r
107 +    test_begin_subtest "${outp}: maxitems = 0"\r
108 +    test_expect_equal "`notmuch search --output=${outp} --maxitems=0 "*"`" ""\r
109 +\r
110 +    test_begin_subtest "${outp}: first does the right thing"\r
111 +    # note: tail -n +N is 1-based\r
112 +    notmuch search --output=${outp} "*" | tail -n +21 >expected\r
113 +    notmuch search --output=${outp} --first=20 "*" >output\r
114 +    test_expect_equal_file expected output\r
115 +\r
116 +    test_begin_subtest "${outp}: first = 0"\r
117 +    notmuch search --output=${outp} "*" >expected\r
118 +    notmuch search --output=${outp} --first=0 "*" >output\r
119 +    test_expect_equal_file expected output\r
120 +\r
121 +    test_begin_subtest "${outp}: negative first"\r
122 +    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
123 +    notmuch search --output=${outp} --first=-20 "*" >output\r
124 +    test_expect_equal_file expected output\r
125 +\r
126 +    test_begin_subtest "${outp}: negative first"\r
127 +    notmuch search --output=${outp} "*" | tail -n 1 >expected\r
128 +    notmuch search --output=${outp} --first=-1 "*" >output\r
129 +    test_expect_equal_file expected output\r
130 +\r
131 +    test_begin_subtest "${outp}: negative first combined with maxitems"\r
132 +    notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected\r
133 +    notmuch search --output=${outp} --first=-20 --maxitems=10 "*" >output\r
134 +    test_expect_equal_file expected output\r
135 +\r
136 +    test_begin_subtest "${outp}: negative first combined with equal maxitems"\r
137 +    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
138 +    notmuch search --output=${outp} --first=-20 --maxitems=20 "*" >output\r
139 +    test_expect_equal_file expected output\r
140 +\r
141 +    test_begin_subtest "${outp}: negative first combined with large maxitems"\r
142 +    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
143 +    notmuch search --output=${outp} --first=-20 --maxitems=50 "*" >output\r
144 +    test_expect_equal_file expected output\r
145 +\r
146 +    test_begin_subtest "${outp}: negative first larger then results"\r
147 +    N=`notmuch count --output=${outp} "*"`\r
148 +    notmuch search --output=${outp} "*" >expected\r
149 +    notmuch search --output=${outp} --first=-$((1 + ${N})) "*" >output\r
150 +    test_expect_equal_file expected output\r
151 +done\r
152 +\r
153 +test_done\r
154 -- \r
155 1.7.5.4\r
156 \r