[PATCH 3/3] test: Add simple tests for the add command

Adam Wolfe Gordon awg+notmuch at xvx.ca
Sat Jul 13 17:45:46 PDT 2013


---
 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



More information about the notmuch mailing list