unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v6 6/6] test: add tests for notmuch search --first and --maxitems
Date: Sun, 13 Nov 2011 23:15:35 +0200	[thread overview]
Message-ID: <60203cbfdcee617a33155e50da9033972fc779f9.1321217854.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1321217854.git.jani@nikula.org>
In-Reply-To: <cover.1321217854.git.jani@nikula.org>

Signed-off-by: Jani Nikula <jani@nikula.org>
---
 test/notmuch-test    |    1 +
 test/search-limiting |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100755 test/search-limiting

diff --git a/test/notmuch-test b/test/notmuch-test
index 587adb5..435b469 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -25,6 +25,7 @@ TESTS="
   search-by-folder
   search-position-overlap-bug
   search-insufficient-from-quoting
+  search-limiting
   json
   multipart
   thread-naming
diff --git a/test/search-limiting b/test/search-limiting
new file mode 100755
index 0000000..45cc0a9
--- /dev/null
+++ b/test/search-limiting
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+test_description='"notmuch search" --first and --maxitems parameters'
+. ./test-lib.sh
+
+add_email_corpus
+
+for outp in messages threads; do
+    test_begin_subtest "${outp}: maxitems does the right thing"
+    notmuch search --output=${outp} "*" | head -n 20 >expected
+    notmuch search --output=${outp} --maxitems=20 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: concatenation of limited searches"
+    notmuch search --output=${outp} "*" | head -n 20 >expected
+    notmuch search --output=${outp} --maxitems=10 "*" >output
+    notmuch search --output=${outp} --maxitems=10 --first=10 "*" >>output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: maxitems larger than result set"
+    N=`notmuch count --output=${outp} "*"`
+    notmuch search --output=${outp} "*" >expected
+    notmuch search --output=${outp} --maxitems=$((1 + ${N})) "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: maxitems = 0"
+    test_expect_equal "`notmuch search --output=${outp} --maxitems=0 "*"`" ""
+
+    test_begin_subtest "${outp}: first does the right thing"
+    # note: tail -n +N is 1-based
+    notmuch search --output=${outp} "*" | tail -n +21 >expected
+    notmuch search --output=${outp} --first=20 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: first = 0"
+    notmuch search --output=${outp} "*" >expected
+    notmuch search --output=${outp} --first=0 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first"
+    notmuch search --output=${outp} "*" | tail -n 20 >expected
+    notmuch search --output=${outp} --first=-20 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first"
+    notmuch search --output=${outp} "*" | tail -n 1 >expected
+    notmuch search --output=${outp} --first=-1 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first combined with maxitems"
+    notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected
+    notmuch search --output=${outp} --first=-20 --maxitems=10 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first combined with equal maxitems"
+    notmuch search --output=${outp} "*" | tail -n 20 >expected
+    notmuch search --output=${outp} --first=-20 --maxitems=20 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first combined with large maxitems"
+    notmuch search --output=${outp} "*" | tail -n 20 >expected
+    notmuch search --output=${outp} --first=-20 --maxitems=50 "*" >output
+    test_expect_equal_file expected output
+
+    test_begin_subtest "${outp}: negative first larger then results"
+    N=`notmuch count --output=${outp} "*"`
+    notmuch search --output=${outp} "*" >expected
+    notmuch search --output=${outp} --first=-$((1 + ${N})) "*" >output
+    test_expect_equal_file expected output
+done
+
+test_done
-- 
1.7.5.4

      parent reply	other threads:[~2011-11-13 21:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-13 21:15 [PATCH v6 0/6] lib/cli: limit number of messages in search results Jani Nikula
2011-11-13 21:15 ` [PATCH v6 1/6] lib: add function to get the number of threads matching a search Jani Nikula
2011-11-13 21:15 ` [PATCH v6 2/6] cli: add options --first and --maxitems to notmuch search Jani Nikula
2011-11-13 23:12   ` Jameson Graef Rollins
2011-11-14 10:34     ` Jani Nikula
2011-11-15  1:20       ` David Bremner
2011-11-13 21:15 ` [PATCH v6 3/6] cli: drop unused code from notmuch count Jani Nikula
2011-11-13 21:15 ` [PATCH v6 4/6] cli: add support for --output parameter in " Jani Nikula
2011-11-13 21:15 ` [PATCH v6 5/6] test: add tests for " Jani Nikula
2011-11-13 21:15 ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60203cbfdcee617a33155e50da9033972fc779f9.1321217854.git.jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).