[PATCH 12/15] test-lib.sh: add test_valid_json
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Apr 28 11:57:20 PDT 2020
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 <dkg at fifthhorseman.net>
---
test/test-lib.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index dd7fdfaa..6f47994e 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 \
--
2.26.2
More information about the notmuch
mailing list