2 test_description="database upgrade"
4 . $(dirname "$0")/test-lib.sh || exit 1
6 dbtarball=database-v1.tar.xz
8 # XXX: Accomplish the same with test lib helpers
9 if [ ! -e ${TEST_DIRECTORY}/test-databases/${dbtarball} ]; then
10 test_subtest_missing_external_prereq_["${dbtarball} - fetch with 'make download-test-databases'"]=t
13 test_begin_subtest "database checksum"
15 '( cd $TEST_DIRECTORY/test-databases &&
16 sha256sum --quiet --check --status ${dbtarball}.sha256 )'
18 tar xf $TEST_DIRECTORY/test-databases/${dbtarball} -C ${MAIL_DIR} --strip-components=1
20 test_begin_subtest "folder: search does not work with old database version"
21 output=$(notmuch search folder:foo)
22 test_expect_equal "$output" ""
24 test_begin_subtest "path: search does not work with old database version"
25 output=$(notmuch search path:foo)
26 test_expect_equal "$output" ""
28 test_begin_subtest "pre upgrade dump"
29 test_expect_success 'notmuch dump | sort > pre-upgrade-dump'
31 test_begin_subtest "database upgrade from format version 1"
32 output=$(notmuch new | sed -e 's/^Backing up tags to .*$/Backing up tags to FILENAME/')
33 test_expect_equal "$output" "\
34 Welcome to a new version of notmuch! Your database will now be upgraded.
35 This process is safe to interrupt.
36 Backing up tags to FILENAME
37 Your notmuch database has now been upgraded.
40 test_begin_subtest "tag backup matches pre-upgrade dump"
41 gunzip -c ${MAIL_DIR}/.notmuch/dump-*.gz | sort > backup-dump
42 test_expect_equal_file pre-upgrade-dump backup-dump
44 test_begin_subtest "folder: no longer matches in the middle of path"
45 output=$(notmuch search folder:baz)
46 test_expect_equal "$output" ""
48 test_begin_subtest "folder: search"
49 output=$(notmuch search --output=files folder:foo | notmuch_search_files_sanitize | sort)
50 test_expect_equal "$output" "MAIL_DIR/foo/06:2,
51 MAIL_DIR/foo/cur/07:2,
52 MAIL_DIR/foo/cur/08:2,
53 MAIL_DIR/foo/new/03:2,
54 MAIL_DIR/foo/new/09:2,
55 MAIL_DIR/foo/new/10:2,"
57 test_begin_subtest "top level folder: search"
58 output=$(notmuch search --output=files folder:'""' | notmuch_search_files_sanitize | sort)
59 # bar/18:2, is a duplicate of cur/51:2,
60 test_expect_equal "$output" "MAIL_DIR/01:2,
90 test_begin_subtest "path: search"
91 output=$(notmuch search --output=files path:"bar" | notmuch_search_files_sanitize | sort)
92 # cur/51:2, is a duplicate of bar/18:2,
93 test_expect_equal "$output" "MAIL_DIR/bar/17:2,
97 test_begin_subtest "top level path: search"
98 output=$(notmuch search --output=files path:'""' | notmuch_search_files_sanitize | sort)
99 test_expect_equal "$output" "MAIL_DIR/01:2,
102 test_begin_subtest "recursive path: search"
103 output=$(notmuch search --output=files path:"bar/**" | notmuch_search_files_sanitize | sort)
104 # cur/51:2, is a duplicate of bar/18:2,
105 test_expect_equal "$output" "MAIL_DIR/bar/17:2,
107 MAIL_DIR/bar/baz/05:2,
108 MAIL_DIR/bar/baz/23:2,
109 MAIL_DIR/bar/baz/24:2,
110 MAIL_DIR/bar/baz/cur/25:2,
111 MAIL_DIR/bar/baz/cur/26:2,
112 MAIL_DIR/bar/baz/new/27:2,
113 MAIL_DIR/bar/baz/new/28:2,
114 MAIL_DIR/bar/cur/19:2,
115 MAIL_DIR/bar/cur/20:2,
116 MAIL_DIR/bar/new/21:2,
117 MAIL_DIR/bar/new/22:2,
120 test_begin_subtest "body: same as unprefixed before reindex"
121 notmuch search --output=messages body:close > OUTPUT
122 notmuch search --output=messages close > EXPECTED
123 test_expect_equal_file EXPECTED OUTPUT
125 test_begin_subtest "body: subset of unprefixed after reindex"
127 notmuch search --output=messages body:close | sort > BODY
128 notmuch search --output=messages close | sort > UNPREFIXED
129 diff -e UNPREFIXED BODY | cut -c2- > OUTPUT
134 test_expect_equal_file EXPECTED OUTPUT