unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] test: Add simple tests for the add command
Date: Sat, 13 Jul 2013 18:45:46 -0600	[thread overview]
Message-ID: <1373762746-22308-4-git-send-email-awg+notmuch@xvx.ca> (raw)
In-Reply-To: <1373762746-22308-1-git-send-email-awg+notmuch@xvx.ca>

---
 test/insert |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/test/insert b/test/insert
index 021edb6..eb23e02 100755
--- a/test/insert
+++ b/test/insert
@@ -18,6 +18,14 @@ gen_insert_msg() {
 	"[body]=\"insert-message\""
 }
 
+gen_add_msg() {
+    generate_message \
+        "[dir]=add-messages/cur" \
+        "[subject]=\"add-subject\"" \
+        "[body]=\"add-message\"" \
+        "[id]=\"add-message\""
+}
+
 test_expect_code 1 "Insert zero-length file" \
     "notmuch insert < /dev/null"
 
@@ -118,4 +126,31 @@ gen_insert_msg
 test_expect_code 1 "Insert message, create invalid subfolder" \
     "notmuch insert --folder=../G --create-folder $gen_msg_filename"
 
+gen_add_msg
+tmp_filename=/tmp/$(basename $gen_msg_filename)
+mv $gen_msg_filename $tmp_filename
+notmuch add $tmp_filename
+test_expect_code 1 "Add message from outside maildir returns 1" \
+    "notmuch add $tmp_filename"
+
+test_begin_subtest "Add message from outside maildir does nothing"
+output=$(notmuch count id:$gen_msg_id)
+test_expect_equal "$output" "0"
+
+test_begin_subtest "Add message from inside maildir"
+gen_add_msg
+notmuch add $gen_msg_filename
+output=$(notmuch count id:$gen_msg_id)
+test_expect_equal "$output" "1"
+
+test_begin_subtest "Add duplicate message"
+gen_add_msg
+notmuch add "$gen_msg_filename"
+output=$(notmuch search --output=files "id:$gen_msg_id" | wc -l)
+test_expect_equal "$output" 2
+
+test_begin_subtest "Adding duplicate message does not change tags"
+output=$(notmuch search --format=json --output=tags "id:$gen_msg_id")
+test_expect_equal_json "$output" '["inbox", "unread"]'
+
 test_done
-- 
1.7.9.5

  parent reply	other threads:[~2013-07-14  0:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-14  0:45 [PATCH 0/3] Introduce the add command Adam Wolfe Gordon
2013-07-14  0:45 ` [PATCH 1/3] cli: Return an error code from add_message_to_database Adam Wolfe Gordon
2013-07-14  0:45 ` [PATCH 2/3] cli: Introduce the add command Adam Wolfe Gordon
2013-07-14  0:45 ` Adam Wolfe Gordon [this message]
2013-07-17 15:23 ` [PATCH 0/3] " Tomi Ollila
2013-07-19 14:48 ` Jameson Graef Rollins
2013-07-21  8:16   ` Mark Walters
2013-07-21 20:25     ` Jameson Graef Rollins
2013-07-21 21:47     ` Vladimir Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373762746-22308-4-git-send-email-awg+notmuch@xvx.ca \
    --to=awg+notmuch@xvx.ca \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).