]> git.cworth.org Git - notmuch/blob - test/T020-compact.sh
NEWS: The minimum supported major version of Emacs is now 24.
[notmuch] / test / T020-compact.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch compact"'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 add_message '[subject]=One'
6 add_message '[subject]=Two'
7 add_message '[subject]=Three'
8
9 notmuch tag +tag1 \*
10 notmuch tag +tag2 subject:Two
11 notmuch tag -tag1 +tag3 subject:Three
12
13 if [ $NOTMUCH_HAVE_XAPIAN_COMPACT -eq 0 ]; then
14     test_begin_subtest "Compact unsupported: error message"
15     output=$(notmuch compact --quiet 2>&1)
16     test_expect_equal "$output" "notmuch was compiled against a xapian version lacking compaction support.
17 Compaction failed: Unsupported operation"
18
19     test_begin_subtest "Compact unsupported: status code"
20     test_expect_code 1 "notmuch compact"
21
22     test_done
23 fi
24
25 test_begin_subtest "Running compact"
26 test_expect_success "notmuch compact --backup=${TEST_DIRECTORY}/xapian.old"
27
28 test_begin_subtest "Compact preserves database"
29 output=$(notmuch search \* | notmuch_search_sanitize)
30 test_expect_equal "$output" "\
31 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
32 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
33 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
34
35 test_begin_subtest "Restoring Backup"
36 test_expect_success 'rm -Rf ${MAIL_DIR}/.notmuch/xapian &&
37      mv ${TEST_DIRECTORY}/xapian.old ${MAIL_DIR}/.notmuch/xapian'
38
39 test_begin_subtest "Checking restored backup"
40 output=$(notmuch search \* | notmuch_search_sanitize)
41 test_expect_equal "$output" "\
42 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
43 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
44 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
45
46 test_done