]> git.notmuchmail.org Git - notmuch/blob - test/T030-config.sh
Merge tag 'debian/0.27-3'
[notmuch] / test / T030-config.sh
1 #!/usr/bin/env bash
2
3 test_description='"notmuch config"'
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 test_begin_subtest "Get string value"
7 test_expect_equal "$(notmuch config get user.name)" "Notmuch Test Suite"
8
9 test_begin_subtest "Get list value"
10 test_expect_equal "$(notmuch config get new.tags)" "\
11 unread
12 inbox"
13
14 test_begin_subtest "Set string value"
15 notmuch config set foo.string "this is a string value"
16 test_expect_equal "$(notmuch config get foo.string)" "this is a string value"
17
18 test_begin_subtest "Set string value again"
19 notmuch config set foo.string "this is another string value"
20 test_expect_equal "$(notmuch config get foo.string)" "this is another string value"
21
22 test_begin_subtest "Set list value"
23 notmuch config set foo.list this "is a" "list value"
24 test_expect_equal "$(notmuch config get foo.list)" "\
25 this
26 is a
27 list value"
28
29 test_begin_subtest "Set list value again"
30 notmuch config set foo.list this "is another" "list value"
31 test_expect_equal "$(notmuch config get foo.list)" "\
32 this
33 is another
34 list value"
35
36 test_begin_subtest "Remove key"
37 notmuch config set foo.remove baz
38 notmuch config set foo.remove
39 test_expect_equal "$(notmuch config get foo.remove)" ""
40
41 test_begin_subtest "Remove non-existent key"
42 notmuch config set foo.nonexistent
43 test_expect_equal "$(notmuch config get foo.nonexistent)" ""
44
45 test_begin_subtest "List all items"
46 notmuch config list 2>&1 | notmuch_config_sanitize > OUTPUT
47
48 if [ "${NOTMUCH_GMIME_MAJOR}" -lt 3 ]; then
49     config_gpg_path="crypto.gpg_path=gpg
50 "
51 fi
52
53 cat <<EOF > EXPECTED
54 Error opening database at MAIL_DIR/.notmuch: No such file or directory
55 database.path=MAIL_DIR
56 user.name=Notmuch Test Suite
57 user.primary_email=test_suite@notmuchmail.org
58 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
59 new.tags=unread;inbox;
60 new.ignore=
61 search.exclude_tags=
62 maildir.synchronize_flags=true
63 ${config_gpg_path}foo.string=this is another string value
64 foo.list=this;is another;list value;
65 built_with.compact=something
66 built_with.field_processor=something
67 built_with.retry_lock=something
68 EOF
69 test_expect_equal_file EXPECTED OUTPUT
70
71 test_begin_subtest "Top level --config=FILE option"
72 cp "${NOTMUCH_CONFIG}" alt-config
73 notmuch --config=alt-config config set user.name "Another Name"
74 test_expect_equal "$(notmuch --config=alt-config config get user.name)" \
75     "Another Name"
76
77 test_begin_subtest "Top level --config:FILE option"
78 test_expect_equal "$(notmuch --config:alt-config config get user.name)" \
79     "Another Name"
80
81 test_begin_subtest "Top level --config<space>FILE option"
82 test_expect_equal "$(notmuch --config  alt-config config get user.name)" \
83     "Another Name"
84
85 test_begin_subtest "Top level --config=FILE option changed the right file"
86 test_expect_equal "$(notmuch config get user.name)" \
87     "Notmuch Test Suite"
88
89 test_begin_subtest "Read config file through a symlink"
90 ln -s alt-config alt-config-link
91 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
92     "Another Name"
93
94 test_begin_subtest "Write config file through a symlink"
95 notmuch --config=alt-config-link config set user.name "Link Name"
96 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
97     "Link Name"
98
99 test_begin_subtest "Writing config file through symlink follows symlink"
100 test_expect_equal "$(readlink alt-config-link)" "alt-config"
101
102 test_begin_subtest "Absolute database path returned"
103 notmuch config set database.path ${HOME}/Maildir
104 test_expect_equal "$(notmuch config get database.path)" \
105                   "${HOME}/Maildir"
106
107 test_begin_subtest "Relative database path properly expanded"
108 notmuch config set database.path Maildir
109 test_expect_equal "$(notmuch config get database.path)" \
110                   "${HOME}/Maildir"
111
112 test_done