3 test_description='"notmuch config"'
4 . $(dirname "$0")/test-lib.sh || exit 1
6 test_begin_subtest "Get string value"
7 test_expect_equal "$(notmuch config get user.name)" "Notmuch Test Suite"
9 test_begin_subtest "Get list value"
10 test_expect_equal "$(notmuch config get new.tags)" "\
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"
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"
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)" "\
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)" "\
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)" ""
41 test_begin_subtest "Remove non-existent key"
42 notmuch config set foo.nonexistent
43 test_expect_equal "$(notmuch config get foo.nonexistent)" ""
45 test_begin_subtest "List all items"
46 notmuch config list > STDOUT 2> STDERR
47 printf "%s\n====\n%s\n" "$(< STDOUT)" "$(< STDERR)" | notmuch_config_sanitize > OUTPUT
50 database.path=MAIL_DIR
51 user.name=Notmuch Test Suite
52 user.primary_email=test_suite@notmuchmail.org
53 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
54 new.tags=unread;inbox;
57 maildir.synchronize_flags=true
58 foo.string=this is another string value
59 foo.list=this;is another;list value;
60 built_with.compact=something
61 built_with.field_processor=something
62 built_with.retry_lock=something
64 Error opening database at MAIL_DIR/.notmuch: No such file or directory
66 test_expect_equal_file EXPECTED OUTPUT
68 test_begin_subtest "Top level --config=FILE option"
69 cp "${NOTMUCH_CONFIG}" alt-config
70 notmuch --config=alt-config config set user.name "Another Name"
71 test_expect_equal "$(notmuch --config=alt-config config get user.name)" \
74 test_begin_subtest "Top level --config:FILE option"
75 test_expect_equal "$(notmuch --config:alt-config config get user.name)" \
78 test_begin_subtest "Top level --config<space>FILE option"
79 test_expect_equal "$(notmuch --config alt-config config get user.name)" \
82 test_begin_subtest "Top level --config=FILE option changed the right file"
83 test_expect_equal "$(notmuch config get user.name)" \
86 test_begin_subtest "Read config file through a symlink"
87 ln -s alt-config alt-config-link
88 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
91 test_begin_subtest "Write config file through a symlink"
92 notmuch --config=alt-config-link config set user.name "Link Name"
93 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
96 test_begin_subtest "Writing config file through symlink follows symlink"
97 test_expect_equal "$(readlink alt-config-link)" "alt-config"
99 test_begin_subtest "Absolute database path returned"
100 notmuch config set database.path ${HOME}/Maildir
101 test_expect_equal "$(notmuch config get database.path)" \
104 test_begin_subtest "Relative database path properly expanded"
105 notmuch config set database.path Maildir
106 test_expect_equal "$(notmuch config get database.path)" \