aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/T130-search-limiting.sh
diff options
context:
space:
mode:
authorGravatar Tomi Ollila <tomi.ollila@iki.fi>2014-01-09 17:18:59 +0200
committerGravatar David Bremner <david@tethera.net>2014-01-13 14:16:46 -0400
commita755c9d6a9099366cc82ba3a4bee8e6d2b83d529 (patch)
treee17400d2996686722eb94404902f62043b764237 /test/T130-search-limiting.sh
parent84719b08f757a6079f4c3331d0c476d19b265948 (diff)
test: renamed test scripts to format T\d\d\d-name.sh
All test scripts to be executed are now named as T\d\d\d-name.sh, numers in increments of 10. This eases adding new tests and developers to see which are test scripts that are executed by test suite and in which order.
Diffstat (limited to 'test/T130-search-limiting.sh')
-rwxr-xr-xtest/T130-search-limiting.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/T130-search-limiting.sh b/test/T130-search-limiting.sh
new file mode 100755
index 00000000..303762cf
--- /dev/null
+++ b/test/T130-search-limiting.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+test_description='"notmuch search" --offset and --limit parameters'
+. ./test-lib.sh
+
+add_email_corpus
+
+for outp in messages threads; do
+ test_begin_subtest "${outp}: limit does the right thing"
+ notmuch search --output=${outp} "*" | head -n 20 >expected
+ notmuch search --output=${outp} --limit=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} --limit=10 "*" >output
+ notmuch search --output=${outp} --limit=10 --offset=10 "*" >>output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: limit larger than result set"
+ N=`notmuch count --output=${outp} "*"`
+ notmuch search --output=${outp} "*" >expected
+ notmuch search --output=${outp} --limit=$((1 + ${N})) "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: limit = 0"
+ test_expect_equal "`notmuch search --output=${outp} --limit=0 "*"`" ""
+
+ test_begin_subtest "${outp}: offset does the right thing"
+ # note: tail -n +N is 1-based
+ notmuch search --output=${outp} "*" | tail -n +21 >expected
+ notmuch search --output=${outp} --offset=20 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: offset = 0"
+ notmuch search --output=${outp} "*" >expected
+ notmuch search --output=${outp} --offset=0 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset"
+ notmuch search --output=${outp} "*" | tail -n 20 >expected
+ notmuch search --output=${outp} --offset=-20 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset"
+ notmuch search --output=${outp} "*" | tail -n 1 >expected
+ notmuch search --output=${outp} --offset=-1 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset combined with limit"
+ notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected
+ notmuch search --output=${outp} --offset=-20 --limit=10 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset combined with equal limit"
+ notmuch search --output=${outp} "*" | tail -n 20 >expected
+ notmuch search --output=${outp} --offset=-20 --limit=20 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset combined with large limit"
+ notmuch search --output=${outp} "*" | tail -n 20 >expected
+ notmuch search --output=${outp} --offset=-20 --limit=50 "*" >output
+ test_expect_equal_file expected output
+
+ test_begin_subtest "${outp}: negative offset larger then results"
+ N=`notmuch count --output=${outp} "*"`
+ notmuch search --output=${outp} "*" >expected
+ notmuch search --output=${outp} --offset=-$((1 + ${N})) "*" >output
+ test_expect_equal_file expected output
+done
+
+test_done