unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob e93c76afb63c9f987b6144be75a29a9ff79543d6 3041 bytes (raw)
name: test/search-limiting 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 output expected

    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 output expected

    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 output expected

    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 output expected

    test_begin_subtest "${outp}: offset = 0"
    notmuch search --output=${outp} "*" >expected
    notmuch search --output=${outp} --offset=0 "*" >output
    test_expect_equal_file output expected

    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 output expected

    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 output expected

    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 output expected

    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 output expected

    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 output expected

    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 output expected
done

test_done

debug log:

solving e93c76a ...
found e93c76a in https://yhetil.org/notmuch/1328141050-30356-3-git-send-email-dmitry.kurochkin@gmail.com/
found 303762c in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 303762cf7bbab4f843e9a6c85a8555d928b98d05	test/search-limiting

applying [1/1] https://yhetil.org/notmuch/1328141050-30356-3-git-send-email-dmitry.kurochkin@gmail.com/
diff --git a/test/search-limiting b/test/search-limiting
index 303762c..e93c76a 100755

Checking patch test/search-limiting...
Applied patch test/search-limiting cleanly.

index at:
100755 e93c76afb63c9f987b6144be75a29a9ff79543d6	test/search-limiting

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).