aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-02-19 08:41:36 -0400
committerDavid Bremner <david@tethera.net>2021-03-27 09:26:14 -0300
commitdd9112e7d8e89e8566b90379f5f3b1461a2d2845 (patch)
tree0dc50fd5aeb6205ca3bbaa99035f5313be7f3b9d /test
parent7f6aae4f64add17d9750d2d8491930e15fad4fe1 (diff)
CLI/config: default to storing all config in external files
Previously the fact that some configuration options were only stored in the database (and thus editing the config file had no effect) was a source of user confusion. This was fixed with the series ending at d9af0af1646. On the other hand, the underlying partition of config options into those stored by default in the database and those stored in the config file remained. This is also confusing, since now some invocations of "notmuch config set" modify the config file, and others silently modify the database instead. With this commit, it is up to the user to decide which configuration to modify. A new "--database" option is provided for notmuch config to enable modifying the configuration information in the database; otherwise the default is to update an external config file.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T030-config.sh20
-rwxr-xr-xtest/T600-named-queries.sh17
-rwxr-xr-xtest/T750-user-header.sh8
3 files changed, 27 insertions, 18 deletions
diff --git a/test/T030-config.sh b/test/T030-config.sh
index c87d35b6..b22d8f29 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -124,4 +124,24 @@ count=$(notmuch count '*')
test_expect_equal "${path} ${count}" \
"Maildir 52"
+test_begin_subtest "Add config to database"
+notmuch new
+key=g${RANDOM}.m${RANDOM}
+value=${RANDOM}
+notmuch config set --database ${key} ${value}
+notmuch dump --include=config > OUTPUT
+cat <<EOF > EXPECTED
+#notmuch-dump batch-tag:3 config
+#@ ${key} ${value}
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "Roundtrip config to/from database"
+notmuch new
+key=g${RANDOM}.m${RANDOM}
+value=${RANDOM}
+notmuch config set --database ${key} ${value}
+output=$(notmuch config get ${key})
+test_expect_equal "${output}" "${value}"
+
test_done
diff --git a/test/T600-named-queries.sh b/test/T600-named-queries.sh
index 0ae8b83d..a7b84995 100755
--- a/test/T600-named-queries.sh
+++ b/test/T600-named-queries.sh
@@ -4,13 +4,13 @@ test_description='named queries'
QUERYSTR="date:2009-11-18..2009-11-18 and tag:unread"
-test_begin_subtest "error adding named query before initializing DB"
-test_expect_code 1 "notmuch config set query.test \"$QUERYSTR\""
+test_begin_subtest "error adding named query to DB before initialization"
+test_expect_code 1 "notmuch config set --database query.test \"$QUERYSTR\""
add_email_corpus
-test_begin_subtest "adding named query"
-test_expect_success "notmuch config set query.test \"$QUERYSTR\""
+test_begin_subtest "adding named query (database)"
+test_expect_success "notmuch config set --database query.test \"$QUERYSTR\""
test_begin_subtest "adding nested named query"
QUERYSTR2="query:test and subject:Maildir"
@@ -32,7 +32,6 @@ test_begin_subtest "dump named queries"
notmuch dump | grep '^#@' > OUTPUT
cat<<EOF > QUERIES.BEFORE
#@ query.test date%3a2009-11-18..2009-11-18%20and%20tag%3aunread
-#@ query.test2 query%3atest%20and%20subject%3aMaildir
EOF
test_expect_equal_file QUERIES.BEFORE OUTPUT
@@ -40,23 +39,21 @@ test_begin_subtest 'dumping large queries'
# This value is just large enough to trigger a limitation of gzprintf
# to 8191 bytes in total (by default).
repeat=1329
-notmuch config set query.big "$(seq -s' ' $repeat)"
+notmuch config set --database query.big "$(seq -s' ' $repeat)"
notmuch dump --include=config > OUTPUT
-notmuch config set query.big ''
+notmuch config set --database query.big
printf "#notmuch-dump batch-tag:3 config\n#@ query.big " > EXPECTED
seq -s'%20' $repeat >> EXPECTED
cat <<EOF >> EXPECTED
#@ query.test date%3a2009-11-18..2009-11-18%20and%20tag%3aunread
-#@ query.test2 query%3atest%20and%20subject%3aMaildir
EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "delete named queries"
notmuch dump > BEFORE
-notmuch config set query.test
+notmuch config set --database query.test
notmuch dump | grep '^#@' > OUTPUT
cat<<EOF > EXPECTED
-#@ query.test2 query%3atest%20and%20subject%3aMaildir
EOF
test_expect_equal_file EXPECTED OUTPUT
diff --git a/test/T750-user-header.sh b/test/T750-user-header.sh
index 586788b3..05f80885 100755
--- a/test/T750-user-header.sh
+++ b/test/T750-user-header.sh
@@ -2,14 +2,6 @@
test_description='indexing user specified headers'
. $(dirname "$0")/test-lib.sh || exit 1
-test_begin_subtest "error adding user header before initializing DB"
-notmuch config set index.header.List List-Id 2>&1 | notmuch_dir_sanitize > OUTPUT
-cat <<EOF > EXPECTED
-notmuch config: Illegal argument for function
-Cannot reopen closed or nonexistent database
-EOF
-test_expect_equal_file EXPECTED OUTPUT
-
add_email_corpus
notmuch search '*' | notmuch_search_sanitize > initial-threads