]> git.cworth.org Git - notmuch/blob - test/T020-compact.sh
emacs/tree: command to toggle search sort order in tree mode
[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 test_begin_subtest "Running compact"
14 test_expect_success "notmuch compact --backup=${TMP_DIRECTORY}/xapian.old"
15
16 test_begin_subtest "Compact preserves database"
17 output=$(notmuch search \* | notmuch_search_sanitize)
18 test_expect_equal "$output" "\
19 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
20 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
21 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
22
23 test_begin_subtest "Restoring Backup"
24 test_expect_success 'rm -Rf ${MAIL_DIR}/.notmuch/xapian &&
25      mv ${TMP_DIRECTORY}/xapian.old ${MAIL_DIR}/.notmuch/xapian'
26
27 test_begin_subtest "Checking restored backup"
28 output=$(notmuch search \* | notmuch_search_sanitize)
29 test_expect_equal "$output" "\
30 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
31 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
32 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
33
34 test_done