]> git.notmuchmail.org Git - notmuch/blob - test/T100-search-by-folder.sh
lib: make folder: prefix literal
[notmuch] / test / T100-search-by-folder.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch search" by folder: (with variations)'
3 . ./test-lib.sh
4
5 add_message '[dir]=bad' '[subject]="To the bone"'
6 add_message '[dir]=.' '[subject]="Top level"'
7 add_message '[dir]=bad/news' '[subject]="Bears"'
8 mkdir -p "${MAIL_DIR}/duplicate/bad/news"
9 cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
10
11 add_message '[dir]=things' '[subject]="These are a few"'
12 add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
13 add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
14
15 test_begin_subtest "Single-world folder: specification (multiple results)"
16 output=$(notmuch search folder:bad folder:bad/news folder:things/bad | notmuch_search_sanitize)
17 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)
18 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)
19 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bites, stings, sad feelings (inbox unread)"
20
21 test_begin_subtest "Top level folder"
22 output=$(notmuch search folder:'""' | notmuch_search_sanitize)
23 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Top level (inbox unread)"
24
25 test_begin_subtest "Two-word path to narrow results to one"
26 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
27 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
28
29 test_begin_subtest "Folder search with --output=files"
30 output=$(notmuch search --output=files folder:bad/news | notmuch_search_files_sanitize)
31 test_expect_equal "$output" "MAIL_DIR/bad/news/msg-003
32 MAIL_DIR/duplicate/bad/news/msg-003"
33
34 test_begin_subtest "After removing duplicate instance of matching path"
35 rm -r "${MAIL_DIR}/bad/news"
36 notmuch new
37 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
38 test_expect_equal "$output" ""
39
40 test_begin_subtest "Folder search with --output=files part #2"
41 output=$(notmuch search --output=files folder:duplicate/bad/news | notmuch_search_files_sanitize)
42 test_expect_equal "$output" "MAIL_DIR/duplicate/bad/news/msg-003"
43
44 test_begin_subtest "After removing duplicate instance of matching path part #2"
45 output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
46 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
47
48 test_begin_subtest "After rename, old path returns nothing"
49 mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
50 notmuch new
51 output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
52 test_expect_equal "$output" ""
53
54 test_begin_subtest "After rename, new path returns result"
55 output=$(notmuch search folder:duplicate/bad/olds | notmuch_search_sanitize)
56 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
57
58 test_done