[PATCH v7 6/6] test: add tests for notmuch search --offset and --limit
authorJani Nikula <jani@nikula.org>
Tue, 15 Nov 2011 20:08:53 +0000 (22:08 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:12 +0000 (09:40 -0800)
91/1a052ccca388ec3a6b42031ac489781b146b76 [new file with mode: 0644]

diff --git a/91/1a052ccca388ec3a6b42031ac489781b146b76 b/91/1a052ccca388ec3a6b42031ac489781b146b76
new file mode 100644 (file)
index 0000000..0e40a33
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C6791429E21\r
+       for <notmuch@notmuchmail.org>; Tue, 15 Nov 2011 12:09:23 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id bzS9ucqcY+o2 for <notmuch@notmuchmail.org>;\r
+       Tue, 15 Nov 2011 12:09:21 -0800 (PST)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 6D8B6431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 15 Nov 2011 12:09:21 -0800 (PST)\r
+Received: by mail-bw0-f53.google.com with SMTP id q10so8918567bka.26\r
+       for <notmuch@notmuchmail.org>; Tue, 15 Nov 2011 12:09:21 -0800 (PST)\r
+Received: by 10.204.154.77 with SMTP id n13mr25515908bkw.83.1321387760959;\r
+       Tue, 15 Nov 2011 12:09:20 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+       [80.220.92.23])\r
+       by mx.google.com with ESMTPS id k26sm18260697fab.8.2011.11.15.12.09.19\r
+       (version=SSLv3 cipher=OTHER); Tue, 15 Nov 2011 12:09:20 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v7 6/6] test: add tests for notmuch search --offset and\r
+ --limit\r
+Date: Tue, 15 Nov 2011 22:08:53 +0200\r
+Message-Id:\r
+ <17f735dd8625b98f71dfee19e2016773c1dd489a.1321386762.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <cover.1321386762.git.jani@nikula.org>\r
+References: <cover.1321386762.git.jani@nikula.org>\r
+In-Reply-To: <cover.1321386762.git.jani@nikula.org>\r
+References: <cover.1321386762.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 15 Nov 2011 20:09:23 -0000\r
+\r
+Signed-off-by: Jani Nikula <jani@nikula.org>\r
+---\r
+ test/notmuch-test    |    1 +\r
+ test/search-limiting |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 72 insertions(+), 0 deletions(-)\r
+ create mode 100755 test/search-limiting\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index 29de30d..adfd589 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -25,6 +25,7 @@ TESTS="\r
+   search-by-folder\r
+   search-position-overlap-bug\r
+   search-insufficient-from-quoting\r
++  search-limiting\r
+   tagging\r
+   json\r
+   multipart\r
+diff --git a/test/search-limiting b/test/search-limiting\r
+new file mode 100755\r
+index 0000000..303762c\r
+--- /dev/null\r
++++ b/test/search-limiting\r
+@@ -0,0 +1,71 @@\r
++#!/usr/bin/env bash\r
++test_description='"notmuch search" --offset and --limit parameters'\r
++. ./test-lib.sh\r
++\r
++add_email_corpus\r
++\r
++for outp in messages threads; do\r
++    test_begin_subtest "${outp}: limit does the right thing"\r
++    notmuch search --output=${outp} "*" | head -n 20 >expected\r
++    notmuch search --output=${outp} --limit=20 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: concatenation of limited searches"\r
++    notmuch search --output=${outp} "*" | head -n 20 >expected\r
++    notmuch search --output=${outp} --limit=10 "*" >output\r
++    notmuch search --output=${outp} --limit=10 --offset=10 "*" >>output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: limit larger than result set"\r
++    N=`notmuch count --output=${outp} "*"`\r
++    notmuch search --output=${outp} "*" >expected\r
++    notmuch search --output=${outp} --limit=$((1 + ${N})) "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: limit = 0"\r
++    test_expect_equal "`notmuch search --output=${outp} --limit=0 "*"`" ""\r
++\r
++    test_begin_subtest "${outp}: offset does the right thing"\r
++    # note: tail -n +N is 1-based\r
++    notmuch search --output=${outp} "*" | tail -n +21 >expected\r
++    notmuch search --output=${outp} --offset=20 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: offset = 0"\r
++    notmuch search --output=${outp} "*" >expected\r
++    notmuch search --output=${outp} --offset=0 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset"\r
++    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
++    notmuch search --output=${outp} --offset=-20 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset"\r
++    notmuch search --output=${outp} "*" | tail -n 1 >expected\r
++    notmuch search --output=${outp} --offset=-1 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset combined with limit"\r
++    notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected\r
++    notmuch search --output=${outp} --offset=-20 --limit=10 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset combined with equal limit"\r
++    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
++    notmuch search --output=${outp} --offset=-20 --limit=20 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset combined with large limit"\r
++    notmuch search --output=${outp} "*" | tail -n 20 >expected\r
++    notmuch search --output=${outp} --offset=-20 --limit=50 "*" >output\r
++    test_expect_equal_file expected output\r
++\r
++    test_begin_subtest "${outp}: negative offset larger then results"\r
++    N=`notmuch count --output=${outp} "*"`\r
++    notmuch search --output=${outp} "*" >expected\r
++    notmuch search --output=${outp} --offset=-$((1 + ${N})) "*" >output\r
++    test_expect_equal_file expected output\r
++done\r
++\r
++test_done\r
+-- \r
+1.7.5.4\r
+\r