]> git.notmuchmail.org Git - notmuch/commitdiff
test: Add compact test
authorBen Gamari <bgamari.foss@gmail.com>
Thu, 31 Oct 2013 04:10:08 +0000 (00:10 -0400)
committerDavid Bremner <bremner@debian.org>
Thu, 31 Oct 2013 10:48:04 +0000 (07:48 -0300)
Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
test/compact [new file with mode: 0755]
test/notmuch-test

diff --git a/test/compact b/test/compact
new file mode 100755 (executable)
index 0000000..5bb5cea
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+test_description='"notmuch compact"'
+. ./test-lib.sh
+
+add_message '[subject]=One'
+add_message '[subject]=Two'
+add_message '[subject]=Three'
+
+notmuch tag +tag1 \*
+notmuch tag +tag2 subject:Two
+notmuch tag -tag1 +tag3 subject:Three
+
+test_expect_success "Running compact" "notmuch compact"
+
+test_begin_subtest "Compact preserves database"
+output=$(notmuch search \* | notmuch_search_sanitize)
+test_expect_equal "$output" "\
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
+
+test_begin_subtest "Restoring backup"
+rm -Rf ${TEST_TMPDIR}/mail/xapian
+mv ${TEST_TMPDIR}/mail/xapian.old ${TEST_TMPDIR}/mail/xapian
+
+output=$(notmuch search \* | notmuch_search_sanitize)
+test_expect_equal "$output" "\
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"
+
+test_done
index aa28bb05e71160c937865c55eb5add3f4ffc02d5..ec94baf3660520e21d1e7a0ca2dbc031499a886a 100755 (executable)
@@ -19,6 +19,7 @@ cd $(dirname "$0")
 TESTS="
   basic
   help-test
+  compact
   config
   setup
   new