2 test_description='"notmuch show" --offset and --limit parameters'
3 . $(dirname "$0")/test-lib.sh || exit 1
10 if [ "$kind" = messages ]; then
11 set -- --unthreaded "$@"
13 notmuch show --body=false --format=text --entire-thread=false "$@" "*" |
14 sed -nre 's/^.message\{.*\<depth:0\>.*/&/p'
17 for outp in messages threads; do
18 test_begin_subtest "$outp: limit does the right thing"
19 show $outp | head -n 20 >expected
20 show $outp --limit=20 >output
21 test_expect_equal_file expected output
23 test_begin_subtest "$outp: concatenation of limited shows"
24 show $outp | head -n 20 >expected
25 show $outp --limit=10 >output
26 show $outp --limit=10 --offset=10 >>output
27 test_expect_equal_file expected output
29 test_begin_subtest "$outp: limit larger than result set"
30 N=$(notmuch count --output=$outp "*")
32 show $outp --limit=$((1 + N)) >output
33 test_expect_equal_file expected output
35 test_begin_subtest "$outp: limit = 0"
36 test_expect_equal "$(show $outp --limit=0)" ""
38 test_begin_subtest "$outp: offset does the right thing"
39 # note: tail -n +N is 1-based
40 show $outp | tail -n +21 >expected
41 show $outp --offset=20 >output
42 test_expect_equal_file expected output
44 test_begin_subtest "$outp: offset = 0"
46 show $outp --offset=0 >output
47 test_expect_equal_file expected output
49 test_begin_subtest "$outp: negative offset"
50 show $outp | tail -n 20 >expected
51 show $outp --offset=-20 >output
52 test_expect_equal_file expected output
54 test_begin_subtest "$outp: negative offset"
55 show $outp | tail -n 1 >expected
56 show $outp --offset=-1 >output
57 test_expect_equal_file expected output
59 test_begin_subtest "$outp: negative offset combined with limit"
60 show $outp | tail -n 20 | head -n 10 >expected
61 show $outp --offset=-20 --limit=10 >output
62 test_expect_equal_file expected output
64 test_begin_subtest "$outp: negative offset combined with equal limit"
65 show $outp | tail -n 20 >expected
66 show $outp --offset=-20 --limit=20 >output
67 test_expect_equal_file expected output
69 test_begin_subtest "$outp: negative offset combined with large limit"
70 show $outp | tail -n 20 >expected
71 show $outp --offset=-20 --limit=50 >output
72 test_expect_equal_file expected output
74 test_begin_subtest "$outp: negative offset larger than results"
75 N=$(notmuch count --output=$outp "*")
77 show $outp --offset=-$((1 + N)) >output
78 test_expect_equal_file expected output