--- /dev/null
+Return-Path: <novalazy@gmail.com>\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 C4277429E2E\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 05:28:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 ERUeKZe7fOTT for <notmuch@notmuchmail.org>;\r
+ Wed, 8 Aug 2012 05:28:41 -0700 (PDT)\r
+Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com\r
+ [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 2E59A431FC4\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 05:28:32 -0700 (PDT)\r
+Received: by pbbro2 with SMTP id ro2so1721964pbb.26\r
+ for <notmuch@notmuchmail.org>; Wed, 08 Aug 2012 05:28:30 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+ :mime-version:content-type:content-transfer-encoding;\r
+ bh=7ct9gJiKLEp0QBxGI6M8OCXSuY8zLroqce9Tgp5w1zg=;\r
+ b=gnEXm4wGb78rBuoSy11sp2zx+DIZ875RmIwJ3SAzjCn/inEffw4qEsrJcgz8SZ3vdJ\r
+ oT8WDSB/fczticViIR1lfAvxv8nICOqSBOJDcaKZX2dkoVOTYlLTxmcRV8l/WZeIPlg3\r
+ 7KAiQ8vwK3iejhMB7N1v4lkoFEcgR6EB7uvKHa7LsTC+66JF6O8aozG+ztUeC0PYyLdM\r
+ VbH9/R/OKnBCH+qJ6kE8N5vYqZyCwGDLJXEL5XqeVHKgVY67/CdvColonVBNg7Lhpyt+\r
+ eLd1tkC5tO87SUhqxYuh9uIijUSF2sq7GV8r3RbEXP46xCD1ef4gQnjPIljihqLN6Fu4\r
+ 3i4Q==\r
+Received: by 10.68.222.167 with SMTP id qn7mr35875794pbc.98.1344428910131;\r
+ Wed, 08 Aug 2012 05:28:30 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+ [220.233.42.215])\r
+ by mx.google.com with ESMTPS id ng8sm13320302pbc.13.2012.08.08.05.28.27\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 08 Aug 2012 05:28:29 -0700 (PDT)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/3] test: conform to content length, encoding fields\r
+Date: Wed, 8 Aug 2012 22:27:52 +1000\r
+Message-Id: <1344428872-12374-4-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.4.4\r
+In-Reply-To: <1344428872-12374-1-git-send-email-novalazy@gmail.com>\r
+References: <1344428872-12374-1-git-send-email-novalazy@gmail.com>\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: Wed, 08 Aug 2012 12:28:45 -0000\r
+\r
+Update tests to expect content-length and content-transfer-encoding\r
+fields in show --format=json output, for leaf parts with omitted body\r
+content.\r
+---\r
+ test/crypto | 30 +++++++++++++++++++++---------\r
+ test/json | 2 +-\r
+ test/multipart | 9 +++++----\r
+ 3 files changed, 27 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/test/crypto b/test/crypto\r
+index 5dd14c4..aa96ec2 100755\r
+--- a/test/crypto\r
++++ b/test/crypto\r
+@@ -61,7 +61,8 @@ expected='[[[{"id": "XXXXX",\r
+ "content-type": "text/plain",\r
+ "content": "This is a test signed message.\n"},\r
+ {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+ "$output" \\r
+@@ -95,7 +96,8 @@ expected='[[[{"id": "XXXXX",\r
+ "content-type": "text/plain",\r
+ "content": "This is a test signed message.\n"},\r
+ {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+ "$output" \\r
+@@ -127,7 +129,8 @@ expected='[[[{"id": "XXXXX",\r
+ "content-type": "text/plain",\r
+ "content": "This is a test signed message.\n"},\r
+ {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+ "$output" \\r
+@@ -196,7 +199,8 @@ expected='[[[{"id": "XXXXX",\r
+ "sigstatus": [],\r
+ "content-type": "multipart/encrypted",\r
+ "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+ {"id": 3,\r
+ "content-type": "multipart/mixed",\r
+ "content": [{"id": 4,\r
+@@ -204,6 +208,8 @@ expected='[[[{"id": "XXXXX",\r
+ "content": "This is a test encrypted message.\n"},\r
+ {"id": 5,\r
+ "content-type": "application/octet-stream",\r
++ "content-length": 28,\r
++ "content-transfer-encoding": "base64",\r
+ "filename": "TESTATTACHMENT"}]}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+@@ -231,9 +237,11 @@ test_expect_equal_file OUTPUT TESTATTACHMENT\r
+ \r
+ test_begin_subtest "decryption failure with missing key"\r
+ mv "${GNUPGHOME}"{,.bak}\r
++# The length of the encrypted attachment varies so must be normalized.\r
+ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \\r
+ | notmuch_json_show_sanitize \\r
+- | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
++ | sed -e 's|"created": [1234567890]*|"created": 946728000|' \\r
++ | sed -e 's|"content-length": 6[1234567890]*|"content-length": 652|')\r
+ expected='[[[{"id": "XXXXX",\r
+ "match": true,\r
+ "excluded": false,\r
+@@ -249,9 +257,11 @@ expected='[[[{"id": "XXXXX",\r
+ "encstatus": [{"status": "bad"}],\r
+ "content-type": "multipart/encrypted",\r
+ "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+ {"id": 3,\r
+- "content-type": "application/octet-stream"}]}]},\r
++ "content-type": "application/octet-stream",\r
++ "content-length": 652}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+ "$output" \\r
+@@ -287,7 +297,8 @@ expected='[[[{"id": "XXXXX",\r
+ "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],\r
+ "content-type": "multipart/encrypted",\r
+ "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+ {"id": 3,\r
+ "content-type": "text/plain",\r
+ "content": "This is another test encrypted message.\n"}]}]},\r
+@@ -342,7 +353,8 @@ expected='[[[{"id": "XXXXX",\r
+ "content-type": "text/plain",\r
+ "content": "This is a test signed message.\n"},\r
+ {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+ []]]]'\r
+ test_expect_equal_json \\r
+ "$output" \\r
+diff --git a/test/json b/test/json\r
+index ac8fa8e..8ce2e8a 100755\r
+--- a/test/json\r
++++ b/test/json\r
+@@ -45,7 +45,7 @@ emacs_deliver_message \\r
+ (insert \"Message-ID: <$id>\n\")"\r
+ output=$(notmuch show --format=json "id:$id")\r
+ filename=$(notmuch search --output=files "id:$id")\r
+-test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"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
++test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"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\", \"content-length\": 12392, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"\r
+ \r
+ test_begin_subtest "Search message: json, utf-8"\r
+ add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""\r
+diff --git a/test/multipart b/test/multipart\r
+index 344ed81..497f3ec 100755\r
+--- a/test/multipart\r
++++ b/test/multipart\r
+@@ -330,7 +330,7 @@ cat <<EOF >EXPECTED\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
+ {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
+ {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
+-{"id": 9, "content-type": "application/pgp-signature"}]}]}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ \r
+@@ -345,7 +345,7 @@ cat <<EOF >EXPECTED\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
+ {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
+ {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
+-{"id": 9, "content-type": "application/pgp-signature"}]}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ \r
+@@ -412,7 +412,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ test_begin_subtest "--format=json --part=9, pgp signature (unverified)"\r
+ notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-{"id": 9, "content-type": "application/pgp-signature"}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ \r
+@@ -636,7 +636,8 @@ cat <<EOF >EXPECTED\r
+ "content-type": "text/plain",\r
+ "content": "And this message is signed.\n\n-Carl\n"}]},\r
+ {"id": 9,\r
+- "content-type": "application/pgp-signature"}]}]}}\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 197}]}]}}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ \r
+-- \r
+1.7.4.4\r
+\r