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 built_with.sexpr_query=something
55 database.autocommit=8000
56 database.mail_root=MAIL_DIR
57 database.path=MAIL_DIR
58 foo.list=this;is another;list value;
59 foo.string=this is another string value
60 maildir.synchronize_flags=true
64 user.name=Notmuch Test Suite
65 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
66 user.primary_email=test_suite@notmuchmail.org
68 test_expect_equal_file EXPECTED OUTPUT
70 test_begin_subtest "Top level --config=FILE option"
71 cp "${NOTMUCH_CONFIG}" alt-config
72 notmuch --config=alt-config config set user.name "Another Name"
73 test_expect_equal "$(notmuch --config=alt-config config get user.name)" \
76 test_begin_subtest "Top level --config:FILE option"
77 test_expect_equal "$(notmuch --config:alt-config config get user.name)" \
80 test_begin_subtest "Top level --config<space>FILE option"
81 test_expect_equal "$(notmuch --config alt-config config get user.name)" \
84 test_begin_subtest "Top level --config=FILE option changed the right file"
85 test_expect_equal "$(notmuch config get user.name)" \
88 test_begin_subtest "Read config file through a symlink"
89 ln -s alt-config alt-config-link
90 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
93 test_begin_subtest "Write config file through a symlink"
94 notmuch --config=alt-config-link config set user.name "Link Name"
95 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
98 test_begin_subtest "Writing config file through symlink follows symlink"
99 test_expect_equal "$(readlink alt-config-link)" "alt-config"
101 test_begin_subtest "Round trip arbitrary key"
102 key=g${RANDOM}.m${RANDOM}
104 notmuch config set ${key} ${value}
105 output=$(notmuch config get ${key})
106 test_expect_equal "${output}" "${value}"
108 test_begin_subtest "Clear arbitrary key"
109 notmuch config set ${key}
110 output=$(notmuch config get ${key})
111 test_expect_equal "${output}" ""
113 db_path=${HOME}/database-path
115 test_begin_subtest "Absolute database path returned"
116 notmuch config set database.path ${HOME}/Maildir
117 test_expect_equal "$(notmuch config get database.path)" \
120 ln -s `pwd`/mail home/Maildir
122 test_begin_subtest "Relative database path expanded"
123 notmuch config set database.path Maildir
124 path=$(notmuch config get database.path | notmuch_dir_sanitize)
125 count=$(notmuch count '*')
126 test_expect_equal "${path} ${count}" \
127 "CWD/home/Maildir 52"
129 test_begin_subtest "Add config to database"
131 key=g${RANDOM}.m${RANDOM}
133 notmuch config set --database ${key} ${value}
134 notmuch dump --include=config > OUTPUT
136 #notmuch-dump batch-tag:3 config
139 test_expect_equal_file EXPECTED OUTPUT
141 test_begin_subtest "Roundtrip config to/from database"
143 key=g${RANDOM}.m${RANDOM}
145 notmuch config set --database ${key} ${value}
146 output=$(notmuch config get ${key})
147 test_expect_equal "${output}" "${value}"
149 test_begin_subtest "set built_with.* yields error"
150 test_expect_code 1 "notmuch config set built_with.compact false"
152 test_begin_subtest "get built_with.{compact,field_processor} prints true"
153 for key in compact field_processor; do
154 notmuch config get built_with.${key}
160 test_expect_equal_file EXPECTED OUTPUT
162 test_begin_subtest "get built_with.nonexistent prints false"
163 output=$(notmuch config get built_with.nonexistent)
164 test_expect_equal "$output" "false"