test: remove json test for search null result, since it's being more properly tested...
[notmuch] / test / json
1 #!/usr/bin/env bash
2 test_description="--format=json output"
3 . ./test-lib.sh
4
5 test_begin_subtest "Show message: json"
6 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
7 output=$(notmuch show --format=json "json-show-message")
8 test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"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>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
9
10 test_begin_subtest "Search message: json"
11 add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
12 output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
13 test_expect_equal "$output" "[{\"thread\": \"XXX\",
14 \"timestamp\": 946728000,
15 \"matched\": 1,
16 \"total\": 1,
17 \"authors\": \"Notmuch Test Suite\",
18 \"subject\": \"json-search-subject\",
19 \"tags\": [\"inbox\", \"unread\"]}]"
20
21 test_begin_subtest "Show message: json, utf-8"
22 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\""
23 output=$(notmuch show --format=json "jsön-show-méssage")
24 test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"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>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
25
26 test_begin_subtest "Search message: json, utf-8"
27 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\""
28 output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize)
29 test_expect_equal "$output" "[{\"thread\": \"XXX\",
30 \"timestamp\": 946728000,
31 \"matched\": 1,
32 \"total\": 1,
33 \"authors\": \"Notmuch Test Suite\",
34 \"subject\": \"json-search-utf8-body-sübjéct\",
35 \"tags\": [\"inbox\", \"unread\"]}]"
36
37 test_done