2 test_description='Various options for reading configuration'
3 . $(dirname "$0")/test-lib.sh || exit 1
6 local test_name=$(basename $0 .sh)
7 cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
12 local profile=${1:-default}
13 if [[ $profile != default ]]; then
14 export NOTMUCH_PROFILE=$profile
17 dir="${HOME}/.config/notmuch/${profile}"
20 CONFIG_PATH=$dir/config
21 mv ${NOTMUCH_CONFIG} ${CONFIG_PATH}
26 local test_name=$(basename $0 .sh)
27 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
30 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
35 test_begin_subtest "count with saved query from config file"
37 query_name="test${RANDOM}"
38 notmuch count query:$query_name > OUTPUT
39 printf "\n[query]\n${query_name} = tag:inbox\n" >> notmuch-config
40 notmuch count query:$query_name >> OUTPUT
46 test_expect_equal_file EXPECTED OUTPUT
48 test_begin_subtest "count with saved query from config file (xdg)"
49 query_name="test${RANDOM}"
51 notmuch count query:$query_name > OUTPUT
52 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
53 notmuch count query:$query_name >> OUTPUT
59 test_expect_equal_file EXPECTED OUTPUT
61 test_begin_subtest "count with saved query from config file (xdg+profile)"
62 query_name="test${RANDOM}"
64 notmuch count query:$query_name > OUTPUT
65 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
66 notmuch count query:$query_name >> OUTPUT
72 test_expect_equal_file EXPECTED OUTPUT
76 #notmuch-dump batch-tag:3 tags
79 #notmuch-dump batch-tag:3 tags
80 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
81 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
82 +inbox +signed +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
83 +inbox +signed +unread -- id:20091117203301.GV3165@dottiness.seas.harvard.edu
84 +inbox +signed +unread -- id:20091118002059.067214ed@hikari
85 +inbox +signed +unread -- id:20091118005040.GA25380@dottiness.seas.harvard.edu
86 +inbox +signed +unread -- id:87iqd9rn3l.fsf@vertex.dottedmag
89 test_begin_subtest "dump with saved query from config file"
91 query_name="test${RANDOM}"
92 CONFIG_PATH=notmuch-config
93 printf "Before:\n" > OUTPUT
94 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
95 printf "\nAfter:\n" >> OUTPUT
96 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
97 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
99 test_expect_equal_file EXPECTED OUTPUT
101 test_begin_subtest "dump with saved query from config file (xdg)"
103 query_name="test${RANDOM}"
105 printf "Before:\n" > OUTPUT
106 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
107 printf "\nAfter:\n" >> OUTPUT
108 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
109 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
111 test_expect_equal_file EXPECTED OUTPUT
113 test_begin_subtest "dump with saved query from config file (xdg+profile)"
115 query_name="test${RANDOM}"
117 printf "Before:\n" > OUTPUT
118 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
119 printf "\nAfter:\n" >> OUTPUT
120 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
121 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
123 test_expect_equal_file EXPECTED OUTPUT
125 test_begin_subtest "restore with xdg config"
127 notmuch dump '*' > EXPECTED
128 notmuch tag -inbox '*'
130 notmuch restore --input=EXPECTED
131 notmuch dump > OUTPUT
133 test_expect_equal_file EXPECTED OUTPUT
135 test_begin_subtest "restore with xdg+profile config"
137 notmuch dump '*' > EXPECTED
138 notmuch tag -inbox '*'
140 notmuch restore --input=EXPECTED
141 notmuch dump > OUTPUT
143 test_expect_equal_file EXPECTED OUTPUT