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 2>&1 | notmuch_config_sanitize > OUTPUT
51 built_with.compact=something
52 built_with.field_processor=something
53 built_with.retry_lock=something
54 database.autocommit=8000
55 database.mail_root=MAIL_DIR
56 database.path=MAIL_DIR
57 foo.list=this;is another;list value;
58 foo.string=this is another string value
59 maildir.synchronize_flags=true
63 user.name=Notmuch Test Suite
64 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
65 user.primary_email=test_suite@notmuchmail.org
67 test_expect_equal_file EXPECTED OUTPUT
69 test_begin_subtest "Top level --config=FILE option"
70 cp "${NOTMUCH_CONFIG}" alt-config
71 notmuch --config=alt-config config set user.name "Another Name"
72 test_expect_equal "$(notmuch --config=alt-config config get user.name)" \
75 test_begin_subtest "Top level --config:FILE option"
76 test_expect_equal "$(notmuch --config:alt-config config get user.name)" \
79 test_begin_subtest "Top level --config<space>FILE option"
80 test_expect_equal "$(notmuch --config alt-config config get user.name)" \
83 test_begin_subtest "Top level --config=FILE option changed the right file"
84 test_expect_equal "$(notmuch config get user.name)" \
87 test_begin_subtest "Read config file through a symlink"
88 ln -s alt-config alt-config-link
89 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
92 test_begin_subtest "Write config file through a symlink"
93 notmuch --config=alt-config-link config set user.name "Link Name"
94 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
97 test_begin_subtest "Writing config file through symlink follows symlink"
98 test_expect_equal "$(readlink alt-config-link)" "alt-config"
100 test_begin_subtest "Round trip arbitrary key"
101 key=g${RANDOM}.m${RANDOM}
103 notmuch config set ${key} ${value}
104 output=$(notmuch config get ${key})
105 test_expect_equal "${output}" "${value}"
107 test_begin_subtest "Clear arbitrary key"
108 notmuch config set ${key}
109 output=$(notmuch config get ${key})
110 test_expect_equal "${output}" ""
112 db_path=${HOME}/database-path
114 test_begin_subtest "Absolute database path returned"
115 notmuch config set database.path ${HOME}/Maildir
116 test_expect_equal "$(notmuch config get database.path)" \
119 ln -s `pwd`/mail home/Maildir
121 test_begin_subtest "Relative database path expanded"
122 notmuch config set database.path Maildir
123 path=$(notmuch config get database.path | notmuch_dir_sanitize)
124 count=$(notmuch count '*')
125 test_expect_equal "${path} ${count}" \
126 "CWD/home/Maildir 52"
128 test_begin_subtest "Add config to database"
130 key=g${RANDOM}.m${RANDOM}
132 notmuch config set --database ${key} ${value}
133 notmuch dump --include=config > OUTPUT
135 #notmuch-dump batch-tag:3 config
138 test_expect_equal_file EXPECTED OUTPUT
140 test_begin_subtest "Roundtrip config to/from database"
142 key=g${RANDOM}.m${RANDOM}
144 notmuch config set --database ${key} ${value}
145 output=$(notmuch config get ${key})
146 test_expect_equal "${output}" "${value}"
148 test_begin_subtest "set built_with.* yields error"
149 test_expect_code 1 "notmuch config set built_with.compact false"
151 test_begin_subtest "get built_with.{compact,field_processor} prints true"
152 for key in compact field_processor; do
153 notmuch config get built_with.${key}
159 test_expect_equal_file EXPECTED OUTPUT
161 test_begin_subtest "get built_with.nonexistent prints false"
162 output=$(notmuch config get built_with.nonexistent)
163 test_expect_equal "$output" "false"