[PATCH v2 4/5] Adding tests for --format=sexp.
authorPeter Feigl <craven@gmx.net>
Tue, 4 Dec 2012 14:46:21 +0000 (15:46 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:27 +0000 (09:51 -0800)
10/c565f1372a988183f6dd30302d78dc595536b0 [new file with mode: 0644]

diff --git a/10/c565f1372a988183f6dd30302d78dc595536b0 b/10/c565f1372a988183f6dd30302d78dc595536b0
new file mode 100644 (file)
index 0000000..db6fc1a
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <nex@nexoid.at>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2C2B8431FB6\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 06:46:48 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.001\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
+       tests=[FREEMAIL_FROM=0.001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id JSSgNIoPXN7w for <notmuch@notmuchmail.org>;\r
+       Tue,  4 Dec 2012 06:46:44 -0800 (PST)\r
+Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240])\r
+       (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 4359A431FD8\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 06:46:42 -0800 (PST)\r
+Received: by mail.nexoid.at (Postfix, from userid 1000)\r
+       id 4963911C10B; Tue,  4 Dec 2012 15:46:41 +0100 (CET)\r
+From: Peter Feigl <craven@gmx.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/5] Adding tests for --format=sexp.\r
+Date: Tue,  4 Dec 2012 15:46:21 +0100\r
+Message-Id: <1354632382-15609-5-git-send-email-craven@gmx.net>\r
+X-Mailer: git-send-email 1.8.0\r
+In-Reply-To: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
+References: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
+In-Reply-To: <1354264143-30173-1-git-send-email-craven@gmx.net>\r
+References: <1354264143-30173-1-git-send-email-craven@gmx.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 04 Dec 2012 14:46:48 -0000\r
+\r
+Add basic tests, the same as for json, for the S-Expression output\r
+format.\r
+---\r
+ test/notmuch-test |  1 +\r
+ test/sexp         | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 49 insertions(+)\r
+ create mode 100755 test/sexp\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index a6ef34f..ca9c3dc 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -31,6 +31,7 @@ TESTS="\r
+   excludes\r
+   tagging\r
+   json\r
++  sexp\r
+   text\r
+   multipart\r
+   thread-naming\r
+diff --git a/test/sexp b/test/sexp\r
+new file mode 100755\r
+index 0000000..fdc9de6\r
+--- /dev/null\r
++++ b/test/sexp\r
+@@ -0,0 +1,48 @@\r
++#!/usr/bin/env bash\r
++test_description="--format=sexp output"\r
++. ./test-lib.sh\r
++\r
++test_begin_subtest "Show message: sexp"\r
++add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc@notmuchmail.org\"" "[reply-to]=\"test_suite+replyto@notmuchmail.org\"" "[body]=\"sexp-show-message\""\r
++output=$(notmuch show --format=sexp "sexp-show-message")\r
++test_expect_equal "$output" "(((((id \"msg-001@notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (Bcc \"test_suite+bcc@notmuchmail.org\") (Reply-To \"test_suite+replyto@notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"sexp-show-message\n\"))))) ())))"\r
++\r
++# This should be the same output as above.\r
++test_begin_subtest "Show message: sexp --body=true"\r
++output=$(notmuch show --format=sexp --body=true "sexp-show-message")\r
++test_expect_equal "$output" "(((((id \"msg-001@notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (Bcc \"test_suite+bcc@notmuchmail.org\") (Reply-To \"test_suite+replyto@notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"sexp-show-message\n\"))))) ())))"\r
++\r
++test_begin_subtest "Show message: sexp --body=false"\r
++output=$(notmuch show --format=sexp --body=false "sexp-show-message")\r
++test_expect_equal "$output" "(((((id \"msg-001@notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (Bcc \"test_suite+bcc@notmuchmail.org\") (Reply-To \"test_suite+replyto@notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\")))) ())))"\r
++\r
++test_begin_subtest "Search message: sexp"\r
++add_message "[subject]=\"sexp-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"sexp-search-message\""\r
++output=$(notmuch search --format=sexp "sexp-search-message" | notmuch_search_sanitize)\r
++test_expect_equal "$output" "(((thread \"0000000000000002\") (timestamp 946728000) (date_relative \"2000-01-01\") (matched 1) (total 1) (authors \"Notmuch Test Suite\") (subject \"sexp-search-subject\") (tags (\"inbox\" \"unread\"))))"\r
++\r
++test_begin_subtest "Show message: sexp, utf-8"\r
++add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""\r
++output=$(notmuch show --format=sexp "jsön-show-méssage")\r
++test_expect_equal "$output" "(((((id \"msg-003@notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-003\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-utf8-body-sübjéct\") (From \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"jsön-show-méssage\n\"))))) ())))"\r
++\r
++test_begin_subtest "Show message: sexp, inline attachment filename"\r
++subject='sexp-show-inline-attachment-filename'\r
++id="sexp-show-inline-attachment-filename@notmuchmail.org"\r
++emacs_deliver_message \\r
++    "$subject" \\r
++    'This is a test message with inline attachment with a filename' \\r
++    "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")\r
++     (message-goto-eoh)\r
++     (insert \"Message-ID: <$id>\n\")"\r
++output=$(notmuch show --format=sexp "id:$id")\r
++filename=$(notmuch search --output=files "id:$id")\r
++test_expect_equal "$output" "(((((id \"sexp-show-inline-attachment-filename@notmuchmail.org\") (match t) (excluded nil) (filename \"$filename\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\")) (headers ((Subject \"sexp-show-inline-attachment-filename\") (From \"Notmuch Test Suite <test_suite@notmuchmail.org>\") (To \"test_suite@notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"multipart/mixed\") (content (((id 2) (content-type \"text/plain\") (content \"This is a test message with inline attachment with a filename\")) ((id 3) (content-type \"application/octet-stream\") (filename \"README\")))))))) ())))"\r
++\r
++test_begin_subtest "Search message: sexp, utf-8"\r
++add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""\r
++output=$(notmuch search --format=sexp "jsön-search-méssage" | notmuch_search_sanitize)\r
++test_expect_equal "$output" "(((thread \"0000000000000005\") (timestamp 946728000) (date_relative \"2000-01-01\") (matched 1) (total 1) (authors \"Notmuch Test Suite\") (subject \"sexp-search-utf8-body-sübjéct\") (tags (\"inbox\" \"unread\"))))"\r
++\r
++\r
++test_done\r
+-- \r
+1.8.0\r
+\r