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