diff options
| author | David Bremner <david@tethera.net> | 2020-12-22 08:13:51 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-02-06 19:11:06 -0400 |
| commit | acc6331baa41a8aa7025924c823251d8f8c3384f (patch) | |
| tree | 5a237e2b900503150931fdd2a2edc9d83e7c03ae /test | |
| parent | d071828bd5f8aee0437aeb4993ffeeaa803c367b (diff) | |
CLI/count: switch to new configuration framework
The main effort is changing from the old argv style config list
iterators to the new more opaque ones provided by the library (and
backed by the database+file config cache).
Diffstat (limited to 'test')
| -rwxr-xr-x | test/T035-read-config.sh | 75 | ||||
| -rwxr-xr-x | test/T140-excludes.sh | 15 |
2 files changed, 90 insertions, 0 deletions
diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh new file mode 100755 index 00000000..38d6c609 --- /dev/null +++ b/test/T035-read-config.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +test_description='Various options for reading configuration' +. $(dirname "$0")/test-lib.sh || exit 1 + +backup_config () { + local test_name=$(basename $0 .sh) + cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name} +} + +xdg_config () { + local dir + local profile=${1:-default} + if [[ $profile != default ]]; then + export NOTMUCH_PROFILE=$profile + fi + backup_config + dir="${HOME}/.config/notmuch/${profile}" + rm -rf $dir + mkdir -p $dir + CONFIG_PATH=$dir/config + mv ${NOTMUCH_CONFIG} ${CONFIG_PATH} + unset NOTMUCH_CONFIG +} + +restore_config () { + local test_name=$(basename $0 .sh) + export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config" + unset CONFIG_PATH + unset NOTMUCH_PROFILE + cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG} +} + +add_email_corpus + +test_begin_subtest "count with saved query from config file" +backup_config +query_name="test${RANDOM}" +notmuch count query:$query_name > OUTPUT +printf "\n[query]\n${query_name} = tag:inbox\n" >> notmuch-config +notmuch count query:$query_name >> OUTPUT +cat <<EOF > EXPECTED +0 +52 +EOF +restore_config +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "count with saved query from config file (xdg)" +query_name="test${RANDOM}" +xdg_config +notmuch count query:$query_name > OUTPUT +printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH} +notmuch count query:$query_name >> OUTPUT +cat <<EOF > EXPECTED +0 +52 +EOF +restore_config +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "count with saved query from config file (xdg+profile)" +query_name="test${RANDOM}" +xdg_config work +notmuch count query:$query_name > OUTPUT +printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH} +notmuch count query:$query_name >> OUTPUT +cat <<EOF > EXPECTED +0 +52 +EOF +restore_config +test_expect_equal_file EXPECTED OUTPUT + + +test_done diff --git a/test/T140-excludes.sh b/test/T140-excludes.sh index cef07095..0cacc41d 100755 --- a/test/T140-excludes.sh +++ b/test/T140-excludes.sh @@ -286,6 +286,21 @@ test_begin_subtest "Count, default exclusion: tag in query (threads)" output=$(notmuch count --output=threads tag:test and tag:deleted) test_expect_equal "$output" "3" +test_begin_subtest "Count, default exclusion, batch" +notmuch count --batch --output=messages<<EOF > OUTPUT +tag:test +tag:test and tag:deleted +tag:test +tag:test and tag:deleted +EOF +cat <<EOF >EXPECTED +2 +4 +2 +4 +EOF +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "Count, exclude=true: tag in query (messages)" output=$(notmuch count --exclude=true tag:test and tag:deleted) test_expect_equal "$output" "4" |
