]> git.cworth.org Git - notmuch/blob - test/search-folder-coherence
cli: command line parsing: allow default for keyword options
[notmuch] / test / search-folder-coherence
1 #!/usr/bin/env bash
2 test_description='folder tags removed and added through file renames remain consistent'
3 . ./test-lib.sh
4
5 test_begin_subtest "No new messages"
6 output=$(NOTMUCH_NEW)
7 test_expect_equal "$output" "No new mail."
8
9
10 test_begin_subtest "Single new message"
11 generate_message
12 file_x=$gen_msg_filename
13 id_x=$gen_msg_id
14 output=$(NOTMUCH_NEW)
15 test_expect_equal "$output" "Added 1 new message to the database."
16
17 test_begin_subtest "Add second folder for same message"
18 dir=$(dirname $file_x)
19 mkdir $dir/spam
20 cp $file_x $dir/spam
21 output=$(NOTMUCH_NEW)
22 test_expect_equal "$output" "No new mail."
23
24
25 test_begin_subtest "Multiple files for same message"
26 cat <<EOF >EXPECTED
27 MAIL_DIR/msg-001
28 MAIL_DIR/spam/msg-001
29 EOF
30 notmuch search --output=files id:$id_x | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
31 test_expect_equal_file OUTPUT EXPECTED
32
33 test_begin_subtest "Test matches folder:spam"
34 output=$(notmuch search folder:spam)
35 test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)"
36
37 test_begin_subtest "Remove folder:spam copy of email"
38 rm $dir/spam/$(basename $file_x)
39 output=$(NOTMUCH_NEW)
40 test_expect_equal "$output" "No new mail. Detected 1 file rename."
41
42 test_begin_subtest "No mails match the folder:spam search"
43 output=$(notmuch search folder:spam)
44 test_expect_equal "$output" ""
45
46 test_done