Update some more recent tests to use /usr/bin/env to find bash
[notmuch] / test / search-by-folder
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]=bad/news' '[subject]="Bears"'
7 mkdir -p "${MAIL_DIR}/duplicate/bad/news"
8 cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
9
10 add_message '[dir]=things' '[subject]="These are a few"'
11 add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
12 add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
13
14 test_begin_subtest "Single-world folder: specification (multiple results)"
15 output=$(notmuch search folder:bad | notmuch_search_sanitize)
16 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)
17 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)
18 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bites, stings, sad feelings (inbox unread)"
19
20 test_begin_subtest "Two-word path to narrow results to one"
21 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
22 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
23
24 test_begin_subtest "After removing duplicate instance of matching path"
25 rm -r "${MAIL_DIR}/bad/news"
26 increment_mtime "${MAIL_DIR}/bad"
27 notmuch new
28 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
29 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
30
31 test_begin_subtest "After rename, old path returns nothing"
32 mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
33 increment_mtime "${MAIL_DIR}/duplicate/bad"
34 notmuch new
35 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
36 test_expect_equal "$output" ""
37
38 test_begin_subtest "After rename, new path returns result"
39 output=$(notmuch search folder:bad/olds | notmuch_search_sanitize)
40 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
41
42 test_done