#!/bin/bash -x

workdir="$(mktemp -d)"
export NOTMUCH_CONFIG="${workdir}/.notmuch-config"
mkdir -p "${workdir}"/messages/{cur,tmp,new}

cat >$NOTMUCH_CONFIG <<EOF
[database]
path=$workdir/messages
EOF

notmuch new
delve -a $workdir/messages/.notmuch/xapian

cat >"${workdir}"/messages/new/test-message.eml <<EOF
From: alice@example.org
To: bob@example.org
Date: Fri, 15 Jan 2016 14:16:46 -0500
Subject: a test message
References: <no-such-message@example.org>
Message-ID: <12345@example.org>
Content-Type: text/plain

This is a test message
EOF

notmuch new
delve -a $workdir/messages/.notmuch/xapian

rm -f "${workdir}"/messages/new/test-message.eml

notmuch new
delve -a $workdir/messages/.notmuch/xapian
