test: Remove unnecessary JSON canonicalization

Format canonicalization of JSON output is no longer necessary, so
remove it.  Value canonicalization (e.g., normalizing thread IDs) is
still necessary, so all of the sanitization functions remain.
This commit is contained in:
Austin Clements 2012-08-02 21:14:48 -04:00 committed by David Bremner
parent a34bb1f9fa
commit 624d1897ce
3 changed files with 12 additions and 33 deletions

View file

@ -18,7 +18,7 @@ test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true
test_begin_subtest "Search message: json" test_begin_subtest "Search message: json"
add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\"" add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
output=$(notmuch search --format=json "json-search-message" | notmuch_json_show_sanitize | notmuch_search_sanitize) output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
test_expect_equal_json "$output" "[{\"thread\": \"XXX\", test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\"timestamp\": 946728000, \"timestamp\": 946728000,
\"date_relative\": \"2000-01-01\", \"date_relative\": \"2000-01-01\",
@ -49,7 +49,7 @@ test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"exclud
test_begin_subtest "Search message: json, utf-8" test_begin_subtest "Search message: json, utf-8"
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\"" 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\""
output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_json_show_sanitize | notmuch_search_sanitize) output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize)
test_expect_equal_json "$output" "[{\"thread\": \"XXX\", test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\"timestamp\": 946728000, \"timestamp\": 946728000,
\"date_relative\": \"2000-01-01\", \"date_relative\": \"2000-01-01\",

View file

@ -7,7 +7,6 @@ test_description="maildir synchronization"
# Avoid including the local value of MAIL_DIR in the result. # Avoid including the local value of MAIL_DIR in the result.
filter_show_json() { filter_show_json() {
sed -e "s|${MAIL_DIR}/|MAIL_DIR/|" sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
echo
} }
# Create the expected maildir structure # Create the expected maildir structure

View file

@ -319,10 +319,8 @@ test_expect_success \
"notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'" "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
test_begin_subtest "--format=json --part=0, full message" test_begin_subtest "--format=json --part=0, full message"
notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ {"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
{"id": 1, "content-type": "multipart/signed", "content": [ {"id": 1, "content-type": "multipart/signed", "content": [
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
@ -337,10 +335,8 @@ EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=1, message body" test_begin_subtest "--format=json --part=1, message body"
notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 1, "content-type": "multipart/signed", "content": [ {"id": 1, "content-type": "multipart/signed", "content": [
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
@ -354,10 +350,8 @@ EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=2, multipart/mixed" test_begin_subtest "--format=json --part=2, multipart/mixed"
notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
@ -369,10 +363,8 @@ EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=3, rfc822 part" test_begin_subtest "--format=json --part=3, rfc822 part"
notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
@ -381,10 +373,8 @@ EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative" test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]} {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
@ -392,46 +382,36 @@ EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=5, rfc822's html part" test_begin_subtest "--format=json --part=5, rfc822's html part"
notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 5, "content-type": "text/html"} {"id": 5, "content-type": "text/html"}
EOF EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=6, rfc822's text part" test_begin_subtest "--format=json --part=6, rfc822's text part"
notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"} {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
EOF EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=7, inline attachment" test_begin_subtest "--format=json --part=7, inline attachment"
notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"} {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}
EOF EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=8, plain text part" test_begin_subtest "--format=json --part=8, plain text part"
notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"} {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
EOF EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
test_begin_subtest "--format=json --part=9, pgp signature (unverified)" test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 9, "content-type": "application/pgp-signature"} {"id": 9, "content-type": "application/pgp-signature"}
EOF EOF
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"