2 test_description='indexing user specified headers'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 test_begin_subtest "error adding user header before initializing DB"
6 notmuch config set index.header.List List-Id 2>&1 | notmuch_dir_sanitize > OUTPUT
8 Error opening database at MAIL_DIR/.notmuch: No such file or directory
10 test_expect_equal_file EXPECTED OUTPUT
14 notmuch search '*' | notmuch_search_sanitize > initial-threads
15 notmuch search --output=messages '*' > initial-message-ids
16 notmuch dump > initial-dump
18 test_begin_subtest "adding illegal prefix name, bad utf8"
19 notmuch config set index.header.$'\xFF' "List-Id" 2>&1 | sed 's/:.*$//' >OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
25 test_begin_subtest "adding illegal prefix name, reserved for notmuch"
26 notmuch config set index.header.list "List-Id" 2>OUTPUT
28 Prefix names starting with lower case letters are reserved: list
30 test_expect_equal_file EXPECTED OUTPUT
32 test_begin_subtest "adding illegal prefix name, non-word character."
33 notmuch config set index.header.l:st "List-Id" 2>OUTPUT
35 Non-word character in prefix name: l:st
37 test_expect_equal_file EXPECTED OUTPUT
39 test_begin_subtest "adding empty prefix name."
40 notmuch config set index.header. "List-Id" 2>OUTPUT
41 Non-word character in prefix name: l:st
43 Empty prefix name: index.header.
45 test_expect_equal_file EXPECTED OUTPUT
48 test_begin_subtest "adding user header"
49 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
51 test_begin_subtest "adding existing user header"
52 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
55 test_begin_subtest "retrieve user header"
56 output=$(notmuch config get index.header.List)
57 test_expect_equal "List-Id" "$output"
59 test_begin_subtest 'reindex after adding header preserves threads'
61 notmuch search '*' | notmuch_search_sanitize > OUTPUT
62 test_expect_equal_file initial-threads OUTPUT
64 test_begin_subtest "List all user headers"
65 notmuch config set index.header.Spam "X-Spam"
66 notmuch config list | grep ^index.header | notmuch_config_sanitize > OUTPUT
68 index.header.List=List-Id
69 index.header.Spam=X-Spam
71 test_expect_equal_file EXPECTED OUTPUT
73 test_begin_subtest "parse user prefix"
74 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:"notmuch"' 2>&1 | grep Tmail >OUTPUT
76 Query((Tmail AND XUList:notmuch@1))
78 test_expect_equal_file EXPECTED OUTPUT
80 test_begin_subtest "parse user prefix, stemmed"
81 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:notmuch' 2>&1 | grep Tmail >OUTPUT
83 Query((Tmail AND ZXUList:notmuch@1))
85 test_expect_equal_file EXPECTED OUTPUT
87 test_begin_subtest "parse user prefix, phrase"
88 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:notmuchmail.org' 2>&1 | grep Tmail >OUTPUT
90 Query((Tmail AND (XUList:notmuchmail@1 PHRASE 2 XUList:org@2)))
92 test_expect_equal_file EXPECTED OUTPUT
94 test_begin_subtest "index user header"
95 notmuch config set index.header.List "List-Id"
97 notmuch search --output=files List:notmuch | notmuch_search_files_sanitize | sort > OUTPUT
99 MAIL_DIR/bar/baz/05:2,
100 MAIL_DIR/bar/baz/23:2,
101 MAIL_DIR/bar/baz/24:2,
102 MAIL_DIR/bar/cur/20:2,
103 MAIL_DIR/bar/new/21:2,
104 MAIL_DIR/bar/new/22:2,
105 MAIL_DIR/foo/cur/08:2,
106 MAIL_DIR/foo/new/03:2,
109 test_expect_equal_file EXPECTED OUTPUT