X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Fjson;h=0badb1d237c9e0ae71cbd7d6bbbdb32b68aba76f;hp=2497613188469de16db82853a7e53c365d5a3962;hb=7fdeb0fb630da0eac355f3c6538f01dba932c5e6;hpb=7263aa9ec3f72bb65a491b2c64345ab5258b24ee diff --git a/test/json b/test/json index 24976131..0badb1d2 100755 --- a/test/json +++ b/test/json @@ -1,15 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash test_description="--format=json output" . ./test-lib.sh 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\"" -output=$($NOTMUCH show --format=json "json-show-message") +output=$(notmuch show --format=json "json-show-message") 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 \", \"To\": \"Notmuch Test Suite \", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" 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\"" -output=$($NOTMUCH search --format=json "json-search-message" | notmuch_search_sanitize) +output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize) test_expect_equal "$output" "[{\"thread\": \"XXX\", \"timestamp\": 946728000, \"matched\": 1, @@ -18,19 +18,14 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\", \"subject\": \"json-search-subject\", \"tags\": [\"inbox\", \"unread\"]}]" -test_begin_subtest "Search by subject (utf-8):" -add_message [subject]=utf8-sübjéct "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" -output=$($NOTMUCH search subject:utf8-sübjéct | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)" - 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\"" -output=$($NOTMUCH show --format=json "jsön-show-méssage") +output=$(notmuch show --format=json "jsön-show-méssage") 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 \", \"To\": \"Notmuch Test Suite \", \"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\"}]}, []]]]" 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\"" -output=$($NOTMUCH search --format=json "jsön-search-méssage" | notmuch_search_sanitize) +output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize) test_expect_equal "$output" "[{\"thread\": \"XXX\", \"timestamp\": 946728000, \"matched\": 1, @@ -39,4 +34,8 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\", \"subject\": \"json-search-utf8-body-sübjéct\", \"tags\": [\"inbox\", \"unread\"]}]" +test_begin_subtest "Search returning no messages" +output=$(notmuch search --format=json "this string had better not match any messages" | notmuch_search_sanitize) +test_expect_equal "$output" "[]" + test_done