2010-12-01 21:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-06-10 08:48:03 +02:00
|
|
|
test_description="--format=json output"
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-09-18 00:25:39 +02:00
|
|
|
test_begin_subtest "Show message: json"
|
|
|
|
add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
|
2010-09-21 01:13:15 +02:00
|
|
|
output=$(notmuch show --format=json "json-show-message")
|
2012-03-01 23:30:41 +01:00
|
|
|
test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"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\": \"json-show-message\n\"}]}, []]]]"
|
2010-06-10 08:48:03 +02:00
|
|
|
|
2010-09-18 00:25:39 +02:00
|
|
|
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\""
|
2010-09-21 01:13:15 +02:00
|
|
|
output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
|
2010-09-18 00:25:39 +02:00
|
|
|
test_expect_equal "$output" "[{\"thread\": \"XXX\",
|
2010-06-10 08:48:03 +02:00
|
|
|
\"timestamp\": 946728000,
|
2011-07-23 11:54:03 +02:00
|
|
|
\"date_relative\": \"2000-01-01\",
|
2010-06-10 08:48:03 +02:00
|
|
|
\"matched\": 1,
|
|
|
|
\"total\": 1,
|
|
|
|
\"authors\": \"Notmuch Test Suite\",
|
|
|
|
\"subject\": \"json-search-subject\",
|
|
|
|
\"tags\": [\"inbox\", \"unread\"]}]"
|
|
|
|
|
2010-09-18 00:25:39 +02:00
|
|
|
test_begin_subtest "Show message: json, utf-8"
|
|
|
|
add_message "[subject]=\"json-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
|
2010-09-21 01:13:15 +02:00
|
|
|
output=$(notmuch show --format=json "jsön-show-méssage")
|
2012-03-01 23:30:41 +01:00
|
|
|
test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-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\"}]}, []]]]"
|
2010-06-10 08:48:03 +02:00
|
|
|
|
2011-07-01 04:03:50 +02:00
|
|
|
test_begin_subtest "Show message: json, inline attachment filename"
|
|
|
|
subject='json-show-inline-attachment-filename'
|
|
|
|
id="json-show-inline-attachment-filename@notmuchmail.org"
|
|
|
|
emacs_deliver_message \
|
|
|
|
"$subject" \
|
|
|
|
'This is a test message with inline attachment with a filename' \
|
|
|
|
"(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
|
|
|
|
(message-goto-eoh)
|
|
|
|
(insert \"Message-ID: <$id>\n\")"
|
|
|
|
output=$(notmuch show --format=json "id:$id")
|
|
|
|
filename=$(notmuch search --output=files "id:$id")
|
2012-03-01 23:30:41 +01:00
|
|
|
test_expect_equal "$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\"}]}]}, []]]]"
|
2011-07-01 04:03:50 +02:00
|
|
|
|
2010-09-18 00:25:39 +02:00
|
|
|
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\""
|
2010-09-21 01:13:15 +02:00
|
|
|
output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize)
|
2010-09-18 00:25:39 +02:00
|
|
|
test_expect_equal "$output" "[{\"thread\": \"XXX\",
|
2010-06-10 08:48:03 +02:00
|
|
|
\"timestamp\": 946728000,
|
2011-07-23 11:54:03 +02:00
|
|
|
\"date_relative\": \"2000-01-01\",
|
2010-06-10 08:48:03 +02:00
|
|
|
\"matched\": 1,
|
|
|
|
\"total\": 1,
|
|
|
|
\"authors\": \"Notmuch Test Suite\",
|
|
|
|
\"subject\": \"json-search-utf8-body-sübjéct\",
|
|
|
|
\"tags\": [\"inbox\", \"unread\"]}]"
|
2010-09-18 00:25:39 +02:00
|
|
|
|
2010-06-10 08:48:03 +02:00
|
|
|
test_done
|