aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-08-25 22:36:43 -0300
committerDavid Bremner <david@tethera.net>2021-02-06 19:02:00 -0400
commitd6bd87a712c6df3126589ec223f4c599fa8450b5 (patch)
tree6c7192be624503d6c9d87ab006b054a5234f9f50 /test
parent867d7352a76e0a8a46e64a035f23edcf7d6f49e4 (diff)
lib/config: add notmuch_config_key_{get,set}
By using an enum we can have better error detection than copy pasting key strings around. The question of what layer this belongs in is a bit tricky. Historically most of the keys are defined by the CLI. On the other hand features like excludes are supported in the library/bindings, and it makes sense to configure them from the library as well. The somewhat long prefix for notmuch_config_t is to avoid collisions with the existing usage in notmuch-client.h.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T590-libconfig.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 6bfbde56..fcd96876 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -202,6 +202,44 @@ test_expect_equal_file EXPECTED OUTPUT
restore_database
backup_database
+test_begin_subtest "get config by key"
+notmuch config set test.key1 overridden
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
+{
+ printf("before = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
+ EXPECT0(notmuch_database_set_config (db, "maildir.synchronize_flags", "false"));
+ printf("after = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+before = true
+after = false
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
+backup_database
+test_begin_subtest "set config by key"
+notmuch config set test.key1 overridden
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
+{
+ printf("before = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
+ EXPECT0(notmuch_config_set (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS, "false"));
+ printf("after = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+before = true
+after = false
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
+backup_database
test_begin_subtest "override config from \${NOTMUCH_CONFIG}"
notmuch config set test.key1 overridden
# second argument omitted to make argv[2] == NULL