]> git.notmuchmail.org Git - notmuch/blob - test/T130-search-limiting.sh
lib: bump SONAME minor version
[notmuch] / test / T130-search-limiting.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch search" --offset and --limit parameters'
3 . ./test-lib.sh
4
5 add_email_corpus
6
7 for outp in messages threads; do
8     test_begin_subtest "${outp}: limit does the right thing"
9     notmuch search --output=${outp} "*" | head -n 20 >expected
10     notmuch search --output=${outp} --limit=20 "*" >output
11     test_expect_equal_file expected output
12
13     test_begin_subtest "${outp}: concatenation of limited searches"
14     notmuch search --output=${outp} "*" | head -n 20 >expected
15     notmuch search --output=${outp} --limit=10 "*" >output
16     notmuch search --output=${outp} --limit=10 --offset=10 "*" >>output
17     test_expect_equal_file expected output
18
19     test_begin_subtest "${outp}: limit larger than result set"
20     N=`notmuch count --output=${outp} "*"`
21     notmuch search --output=${outp} "*" >expected
22     notmuch search --output=${outp} --limit=$((1 + ${N})) "*" >output
23     test_expect_equal_file expected output
24
25     test_begin_subtest "${outp}: limit = 0"
26     test_expect_equal "`notmuch search --output=${outp} --limit=0 "*"`" ""
27
28     test_begin_subtest "${outp}: offset does the right thing"
29     # note: tail -n +N is 1-based
30     notmuch search --output=${outp} "*" | tail -n +21 >expected
31     notmuch search --output=${outp} --offset=20 "*" >output
32     test_expect_equal_file expected output
33
34     test_begin_subtest "${outp}: offset = 0"
35     notmuch search --output=${outp} "*" >expected
36     notmuch search --output=${outp} --offset=0 "*" >output
37     test_expect_equal_file expected output
38
39     test_begin_subtest "${outp}: negative offset"
40     notmuch search --output=${outp} "*" | tail -n 20 >expected
41     notmuch search --output=${outp} --offset=-20 "*" >output
42     test_expect_equal_file expected output
43
44     test_begin_subtest "${outp}: negative offset"
45     notmuch search --output=${outp} "*" | tail -n 1 >expected
46     notmuch search --output=${outp} --offset=-1 "*" >output
47     test_expect_equal_file expected output
48
49     test_begin_subtest "${outp}: negative offset combined with limit"
50     notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected
51     notmuch search --output=${outp} --offset=-20 --limit=10 "*" >output
52     test_expect_equal_file expected output
53
54     test_begin_subtest "${outp}: negative offset combined with equal limit"
55     notmuch search --output=${outp} "*" | tail -n 20 >expected
56     notmuch search --output=${outp} --offset=-20 --limit=20 "*" >output
57     test_expect_equal_file expected output
58
59     test_begin_subtest "${outp}: negative offset combined with large limit"
60     notmuch search --output=${outp} "*" | tail -n 20 >expected
61     notmuch search --output=${outp} --offset=-20 --limit=50 "*" >output
62     test_expect_equal_file expected output
63
64     test_begin_subtest "${outp}: negative offset larger then results"
65     N=`notmuch count --output=${outp} "*"`
66     notmuch search --output=${outp} "*" >expected
67     notmuch search --output=${outp} --offset=-$((1 + ${N})) "*" >output
68     test_expect_equal_file expected output
69 done
70
71 test_done