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"
14 notmuch config get new.tags | sort > OUTPUT
15 test_expect_equal_file EXPECTED OUTPUT
17 test_begin_subtest "Set string value"
18 notmuch config set foo.string "this is a string value"
19 test_expect_equal "$(notmuch config get foo.string)" "this is a string value"
21 test_begin_subtest "Set string value again"
22 notmuch config set foo.string "this is another string value"
23 test_expect_equal "$(notmuch config get foo.string)" "this is another string value"
25 test_begin_subtest "Set list value"
26 notmuch config set foo.list this "is a" "list value"
27 test_expect_equal "$(notmuch config get foo.list)" "\
32 test_begin_subtest "Set list value again"
33 notmuch config set foo.list this "is another" "list value"
34 test_expect_equal "$(notmuch config get foo.list)" "\
39 test_begin_subtest "Remove key"
40 notmuch config set foo.remove baz
41 notmuch config set foo.remove
42 test_expect_equal "$(notmuch config get foo.remove)" ""
44 test_begin_subtest "Remove non-existent key"
45 notmuch config set foo.nonexistent
46 test_expect_equal "$(notmuch config get foo.nonexistent)" ""
48 test_begin_subtest "List all items"
49 notmuch config list > STDOUT 2> STDERR
50 printf "%s\n====\n%s\n" "$(< STDOUT)" "$(< STDERR)" | notmuch_config_sanitize > OUTPUT
53 database.path=MAIL_DIR
54 user.name=Notmuch Test Suite
55 user.primary_email=test_suite@notmuchmail.org
56 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
57 new.tags=unread;inbox;
60 maildir.synchronize_flags=true
61 foo.string=this is another string value
62 foo.list=this;is another;list value;
63 built_with.compact=something
64 built_with.field_processor=something
65 built_with.retry_lock=something
67 Error: Cannot open database at MAIL_DIR/.notmuch: No such file or directory.
69 test_expect_equal_file EXPECTED OUTPUT
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)" \
77 test_begin_subtest "Top level --config:FILE option"
78 test_expect_equal "$(notmuch --config:alt-config config get user.name)" \
81 test_begin_subtest "Top level --config<space>FILE option"
82 test_expect_equal "$(notmuch --config alt-config config get user.name)" \
85 test_begin_subtest "Top level --config=FILE option changed the right file"
86 test_expect_equal "$(notmuch config get user.name)" \
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)" \
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)" \
99 test_begin_subtest "Writing config file through symlink follows symlink"
100 test_expect_equal "$(readlink alt-config-link)" "alt-config"
102 test_begin_subtest "Round trip arbitrary key"
103 key=g${RANDOM}.m${RANDOM}
105 notmuch config set ${key} ${value}
106 output=$(notmuch config get ${key})
107 test_expect_equal "${output}" "${value}"
109 test_begin_subtest "Clear arbitrary key"
110 notmuch config set ${key}
111 output=$(notmuch config get ${key})
112 test_expect_equal "${output}" ""
114 db_path=${HOME}/database-path
116 test_begin_subtest "Absolute database path returned"
117 notmuch config set database.path ${HOME}/Maildir
118 test_expect_equal "$(notmuch config get database.path)" \
121 ln -s `pwd`/mail home/Maildir
123 test_begin_subtest "Relative database path expanded in open"
124 notmuch config set database.path Maildir
125 path=$(notmuch config get database.path)
126 count=$(notmuch count '*')
127 test_expect_equal "${path} ${count}" \