]> git.cworth.org Git - notmuch/blobdiff - test/T055-path-config.sh
CLI/new: support split database and mail location
[notmuch] / test / T055-path-config.sh
index c6920ca90631bd772a19a8521d868ab52d488fbf..6df17f80f02067ef6444e40a174a78ad150dbcea 100755 (executable)
@@ -27,9 +27,17 @@ split_config () {
     DATABASE_PATH=$dir
 }
 
+symlink_config () {
+    local dir
+    backup_config
+    dir="$TMP_DIRECTORY/link.$test_count"
+    ln -s $MAIL_DIR $dir
+    notmuch config set database.path $dir
+    notmuch config set database.mail_root $MAIL_DIR
+    unset DATABASE_PATH
+}
 
-
-for config in traditional split; do
+for config in traditional split symlink; do
     # start each set of tests with a known set of messages
     add_email_corpus
 
@@ -41,6 +49,9 @@ for config in traditional split; do
            split_config
            mv mail/.notmuch/xapian $DATABASE_PATH
            ;;
+       symlink)
+           symlink_config
+           ;;
     esac
 
     test_begin_subtest "count ($config)"
@@ -84,6 +95,47 @@ EOF
     notmuch search --output=messages '*' > OUTPUT
     test_expect_equal_file EXPECTED OUTPUT
 
+    test_begin_subtest "use existing database ($config)"
+    output=$(notmuch new)
+    test_expect_equal "$output" 'No new mail.'
+
+    test_begin_subtest "create database ($config)"
+    rm -rf $DATABASE_PATH/{.notmuch,}/xapian
+    notmuch new
+    output=$(notmuch count '*')
+    test_expect_equal "$output" '52'
+
+    test_begin_subtest "detect new files ($config)"
+    generate_message
+    generate_message
+    notmuch new
+    output=$(notmuch count '*')
+    test_expect_equal "$output" '54'
+
+    test_begin_subtest "Show a raw message ($config)"
+    add_message
+    notmuch show --format=raw id:$gen_msg_id > OUTPUT
+    test_expect_equal_file $gen_msg_filename OUTPUT
+    rm -f $gen_msg_filename
+
+    test_begin_subtest "reply ($config)"
+    add_message '[from]="Sender <sender@example.com>"' \
+               [to]=test_suite@notmuchmail.org \
+               [subject]=notmuch-reply-test \
+               '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
+               '[body]="basic reply test"'
+    notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
+    cat <<EOF > EXPECTED
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+Subject: Re: notmuch-reply-test
+To: Sender <sender@example.com>
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
+> basic reply test
+EOF
+    test_expect_equal_file EXPECTED OUTPUT
     restore_config
 done