[PATCH 05/14] test-lib.sh: add test_valid_json
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Dec 3 21:51:53 PST 2019
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 7f8a3a4d..a54ae40f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -503,6 +503,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.24.0
More information about the notmuch
mailing list