unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 38d6c609dca12e5f59f72d96dbb5eb5d72c03328 1863 bytes (raw)
name: test/T035-read-config.sh 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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

debug log:

solving 38d6c609 ...
found 38d6c609 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).