[PATCH v2 7/8] Tests for mbox support
Ethan Glasser-Camp
ethan.glasser.camp at gmail.com
Sun Jul 1 09:39:49 PDT 2012
These are simple tests of one single mbox.
Signed-off-by: Ethan Glasser-Camp <ethan at betacantrips.com>
---
The test uses bash arrays, which have a slightly odd syntax for
appending.
test/mbox | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
test/notmuch-test | 1 +
2 files changed, 64 insertions(+)
create mode 100755 test/mbox
diff --git a/test/mbox b/test/mbox
new file mode 100755
index 0000000..a6dab99
--- /dev/null
+++ b/test/mbox
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='basic mbox support'
+. ./test-lib.sh
+
+mkdir -p $MAIL_DIR/some-mboxes/subdir $MAIL_DIR/database $MAIL_DIR/corpus
+
+# The Content-Length headers here include the final newline (added later).
+generate_message '[body]="Mbox message 1."' '[header]="Content-Length: 16"' "[dir]=corpus"
+generate_message '[body]="Mbox message 2. Longer."' '[header]="Content-Length: 24"' "[dir]=corpus"
+generate_message '[body]="Mbox message 3."' "[dir]=corpus"
+generate_message '[body]="Mbox message 4."' "[dir]=corpus"
+generate_message '[body]="Mbox message 5. Last message."' '[header]="Content-Length: 30"' "[dir]=corpus"
+
+MBOX1=$MAIL_DIR/some-mboxes/first.mbox
+declare -a starts lengths
+
+for x in $MAIL_DIR/corpus/*; do
+ echo "From MAILER-DAEMON Sat Jan 3 01:05:34 1996" >> $MBOX1
+ starts+=(`wc -c $MBOX1 | cut -f 1 -d ' '`)
+ cat $x >> $MBOX1
+ lengths+=(`wc -c $x | cut -f 1 -d ' '`)
+ # Final newline
+ echo >> $MBOX1
+done
+
+notmuch config set database.path $MAIL_DIR/database
+notmuch config set new.scan mbox://$MAIL_DIR/some-mboxes
+
+test_begin_subtest "read a small mbox (5 messages)"
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "Added 5 new messages to the database."
+
+test_begin_subtest "search"
+output=$(notmuch search '*' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #2 (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #3 (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #4 (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #5 (inbox unread)"
+
+test_begin_subtest "show (mboxcl)"
+output=$(notmuch show "Test message #1" | grep -o "filename:[^ ]*")
+test_expect_equal "$output" "filename:mbox://$MAIL_DIR/some-mboxes/first.mbox#${starts[0]}+${lengths[0]}"
+
+test_begin_subtest "show doesn't append an extra space at the end (mboxcl)"
+output=$(notmuch show --format=raw "Test message #1" )
+original=$(cat $MAIL_DIR/corpus/msg-001)
+test_expect_equal "$output" "$original"
+
+test_begin_subtest "show (non-cl)"
+output=$(notmuch show "Test message #3" | grep -o "filename:[^ ]*")
+test_expect_equal "$output" "filename:mbox://$MAIL_DIR/some-mboxes/first.mbox#${starts[2]}+${lengths[2]}"
+
+test_begin_subtest "show doesn't append an extra space at the end (non-cl)"
+output=$(notmuch show --format=raw "Test message #3" )
+original=$(cat $MAIL_DIR/corpus/msg-003)
+test_expect_equal "$output" "$original"
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index bfad5d3..8cbb2cd 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -47,6 +47,7 @@ TESTS="
emacs-large-search-buffer
emacs-subject-to-filename
maildir-sync
+ mbox
crypto
symbol-hiding
search-folder-coherence
--
1.7.9.5
More information about the notmuch
mailing list