]> git.notmuchmail.org Git - notmuch/blob - test/T750-user-header.sh
75fb1635f34878d4e57695b0342b5491bae99081
[notmuch] / test / T750-user-header.sh
1 #!/usr/bin/env bash
2 test_description='indexing user specified headers'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
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
7 cat <<EOF > EXPECTED
8 Error opening database at MAIL_DIR/.notmuch: No such file or directory
9 EOF
10 test_expect_equal_file EXPECTED OUTPUT
11
12 add_email_corpus
13
14 notmuch search '*' | notmuch_search_sanitize > initial-threads
15 notmuch search --output=messages '*' > initial-message-ids
16 notmuch dump > initial-dump
17
18 test_begin_subtest "adding user header"
19 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
20
21 test_begin_subtest "adding existing user header"
22 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
23
24
25 test_begin_subtest "retrieve user header"
26 output=$(notmuch config get index.header.List)
27 test_expect_equal "List-Id" "$output"
28
29 test_begin_subtest 'reindex after adding header preserves threads'
30 notmuch reindex '*'
31 notmuch search '*' | notmuch_search_sanitize > OUTPUT
32 test_expect_equal_file initial-threads OUTPUT
33
34 test_begin_subtest "List all user headers"
35 notmuch config set index.header.Spam "X-Spam"
36 notmuch config list | grep ^index.header | notmuch_config_sanitize > OUTPUT
37 cat <<EOF > EXPECTED
38 index.header.List=List-Id
39 index.header.Spam=X-Spam
40 EOF
41 test_expect_equal_file EXPECTED OUTPUT
42
43 test_done