[PATCH 2/4] test: sanitize Date and timestamp fields in json
authorDavid Bremner <david@tethera.net>
Sun, 8 Dec 2013 15:52:24 +0000 (23:52 +0800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:39 +0000 (09:58 -0800)
36/0941f80c173ce281ac257115d897a05d60abc2 [new file with mode: 0644]

diff --git a/36/0941f80c173ce281ac257115d897a05d60abc2 b/36/0941f80c173ce281ac257115d897a05d60abc2
new file mode 100644 (file)
index 0000000..4e2e805
--- /dev/null
@@ -0,0 +1,117 @@
+Return-Path: <bremner@tesseract.cs.unb.ca>\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 1CF42431E82\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Dec 2013 07:52:57 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 GZ4Rn0sg1t62 for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Dec 2013 07:52:49 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 42953431FDA\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Dec 2013 07:52:49 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+       (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+       id 1Vpgf1-0006AE-8s; Sun, 08 Dec 2013 11:52:47 -0400\r
+Received: (nullmailer pid 22780 invoked by uid 1000); Sun, 08 Dec 2013\r
+       15:52:31 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] test: sanitize Date and timestamp fields in json\r
+Date: Sun,  8 Dec 2013 23:52:24 +0800\r
+Message-Id: <1386517946-22054-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.4.3\r
+In-Reply-To: <1386517946-22054-1-git-send-email-david@tethera.net>\r
+References: <1386517946-22054-1-git-send-email-david@tethera.net>\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: Sun, 08 Dec 2013 15:52:57 -0000\r
+\r
+Eventually we want test messages to have distinct dates to avoid\r
+reproducability problems. This sanitization will prevent some test\r
+failures when that change is made.\r
+\r
+Replace the use of a local function in maildir-sync with\r
+notmuch_json_show_sanitize\r
+---\r
+ test/maildir-sync | 15 +++++----------\r
+ test/test-lib.sh  |  4 +++-\r
+ 2 files changed, 8 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/test/maildir-sync b/test/maildir-sync\r
+index 33d2c58..3186e70 100755\r
+--- a/test/maildir-sync\r
++++ b/test/maildir-sync\r
+@@ -4,11 +4,6 @@ test_description="maildir synchronization"\r
\r
+ . ./test-lib.sh\r
\r
+-# Avoid including the local value of MAIL_DIR in the result.\r
+-filter_show_json() {\r
+-    sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"\r
+-}\r
+-\r
+ # Create the expected maildir structure\r
+ mkdir $MAIL_DIR/cur\r
+ mkdir $MAIL_DIR/new\r
+@@ -40,18 +35,18 @@ output=$(cd ${MAIL_DIR}/cur; ls -1 adding-replied*)\r
+ test_expect_equal "$output" "adding-replied-tag:2,RS"\r
\r
+ test_begin_subtest "notmuch show works with renamed file (without notmuch new)"\r
+-output=$(notmuch show --format=json id:${gen_msg_id} | filter_show_json)\r
+-test_expect_equal_json "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",\r
++output=$(notmuch show --format=json id:${gen_msg_id} | notmuch_json_show_sanitize)\r
++test_expect_equal_json "$output" '[[[{"id": "XXXXX",\r
+ "match": true,\r
+ "excluded": false,\r
+-"filename": "MAIL_DIR/cur/adding-replied-tag:2,RS",\r
+-"timestamp": 978709437,\r
++"filename": "YYYYY",\r
++"timestamp": 42,\r
+ "date_relative": "2001-01-05",\r
+ "tags": ["inbox","replied"],\r
+ "headers": {"Subject": "Adding replied tag",\r
+ "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+ "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+-"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
++"Date": "GENERATED_DATE"},\r
+ "body": [{"id": 1,\r
+ "content-type": "text/plain",\r
+ "content": "This is just a test message (#3)\n"}]},\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 8611ba5..9d2f805 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -625,7 +625,9 @@ notmuch_json_show_sanitize ()\r
+ {\r
+     sed \\r
+       -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \\r
+-      -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g'\r
++      -e 's|"Date": "Fri[^"]*0000"|"Date": "GENERATED_DATE"|g' \\r
++      -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g' \\r
++      -e 's|"timestamp": 97.......|"timestamp": 42|g'\r
+ }\r
\r
+ notmuch_emacs_error_sanitize ()\r
+-- \r
+1.8.4.3\r
+\r