2 test_description='Configuration of mail-root and database path'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 test_require_external_prereq xapian-metdata
8 local test_name=$(basename $0 .sh)
9 cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
13 local test_name=$(basename $0 .sh)
14 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
19 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
25 dir="$TMP_DIRECTORY/database.$test_count"
28 notmuch config set database.path $dir
29 notmuch config set database.mail_root $MAIL_DIR
31 XAPIAN_PATH="$dir/xapian"
37 dir="$TMP_DIRECTORY/link.$test_count"
39 notmuch config set database.path $dir
40 notmuch config set database.mail_root $MAIL_DIR
41 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
47 local profile=${1:-default}
49 if [[ $profile != default ]]; then
50 export NOTMUCH_PROFILE=$profile
54 DATABASE_PATH="${HOME}/.local/share/notmuch/${profile}"
56 mkdir -p $DATABASE_PATH
58 config_dir="${HOME}/.config/notmuch/${profile}"
59 mkdir -p ${config_dir}
60 CONFIG_PATH=$config_dir/config
61 mv ${NOTMUCH_CONFIG} $CONFIG_PATH
64 XAPIAN_PATH="${DATABASE_PATH}/xapian"
65 notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
66 notmuch --config=${CONFIG_PATH} config set database.path
69 for config in traditional split XDG XDG+profile symlink; do
70 #start each set of tests with an known set of messages
76 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
80 mv mail/.notmuch/xapian $DATABASE_PATH
84 mv mail/.notmuch/xapian $DATABASE_PATH
88 mv mail/.notmuch/xapian $DATABASE_PATH
95 test_begin_subtest "count ($config)"
96 output=$(notmuch count '*')
97 test_expect_equal "$output" '52'
99 test_begin_subtest "count+tag ($config)"
101 notmuch tag +$tag '*'
102 output=$(notmuch count tag:$tag)
103 notmuch tag -$tag '*'
104 test_expect_equal "$output" '52'
106 test_begin_subtest "address ($config)"
107 notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
109 Carl Worth <cworth@cworth.org>
110 notmuch@notmuchmail.org
112 test_expect_equal_file EXPECTED OUTPUT
114 test_begin_subtest "dump ($config)"
115 notmuch dump is:attachment and is:signed | sort > OUTPUT
117 #notmuch-dump batch-tag:3 config,properties,tags
118 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
119 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
121 test_expect_equal_file EXPECTED OUTPUT
123 test_begin_subtest "dump + tag + restore ($config)"
124 notmuch dump '*' > EXPECTED
125 notmuch tag -inbox '*'
126 notmuch restore < EXPECTED
127 notmuch dump > OUTPUT
128 test_expect_equal_file EXPECTED OUTPUT
130 test_begin_subtest "reindex ($config)"
131 notmuch search --output=messages '*' > EXPECTED
133 notmuch search --output=messages '*' > OUTPUT
134 test_expect_equal_file EXPECTED OUTPUT
136 test_begin_subtest "use existing database ($config)"
137 output=$(notmuch new)
138 test_expect_equal "$output" 'No new mail.'
140 test_begin_subtest "create database ($config)"
141 rm -rf $DATABASE_PATH/{.notmuch,}/xapian
143 output=$(notmuch count '*')
144 test_expect_equal "$output" '52'
146 test_begin_subtest "detect new files ($config)"
150 output=$(notmuch count '*')
151 test_expect_equal "$output" '54'
153 test_begin_subtest "Show a raw message ($config)"
155 notmuch show --format=raw id:$gen_msg_id > OUTPUT
156 test_expect_equal_file $gen_msg_filename OUTPUT
157 rm -f $gen_msg_filename
159 test_begin_subtest "reply ($config)"
160 add_message '[from]="Sender <sender@example.com>"' \
161 [to]=test_suite@notmuchmail.org \
162 [subject]=notmuch-reply-test \
163 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
164 '[body]="basic reply test"'
165 notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
167 From: Notmuch Test Suite <test_suite@notmuchmail.org>
168 Subject: Re: notmuch-reply-test
169 To: Sender <sender@example.com>
170 In-Reply-To: <${gen_msg_id}>
171 References: <${gen_msg_id}>
173 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
176 test_expect_equal_file EXPECTED OUTPUT
177 test_begin_subtest "insert+search ($config)"
179 "[subject]=\"insert-subject\"" \
180 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
181 "[body]=\"insert-message\""
182 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
183 notmuch insert < "$gen_msg_filename"
184 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
185 test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
188 test_begin_subtest "compact+search ($config)"
189 notmuch search --output=messages '*' | sort > EXPECTED
191 notmuch search --output=messages '*' | sort > OUTPUT
192 test_expect_equal_file EXPECTED OUTPUT
194 test_begin_subtest "upgrade backup ($config)"
195 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
196 xapian-metadata set $XAPIAN_PATH features "$features"
197 output=$(notmuch new | grep Welcome)
200 "Welcome to a new version of notmuch! Your database will now be upgraded."