From: Daniel Kahn Gillmor Date: Tue, 28 Apr 2020 18:57:20 +0000 (-0400) Subject: test-lib.sh: add test_valid_json X-Git-Tag: archive/debian/0.30_rc0-1~31 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=488e91f42b95c116b387212c90ea47c43c716f5b test-lib.sh: add test_valid_json This test does exactly what it says on the tin. It expects JSON data to be parseable by Python, at least. Signed-off-by: Daniel Kahn Gillmor --- diff --git a/test/test-lib.sh b/test/test-lib.sh index cb5bb894..43fffa09 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -524,6 +524,12 @@ test_expect_equal_json () { test_expect_equal "$output" "$expected" "$@" } +# Ensure that the argument is valid JSON data. +test_valid_json () { + PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "import sys, json; json.load(sys.stdin)" <<<"$1" + test_expect_equal "$?" 0 +} + # Sort the top-level list of JSON data from stdin. test_sort_json () { PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \