From 36057afa5a1681a48da254dbc204e225e391a413 Mon Sep 17 00:00:00 2001 From: Seth House Date: Wed, 30 Sep 2015 00:22:55 -0600 Subject: [PATCH] Add unit test for jq filters that contain a pipe character --- tests/unit.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit.sh b/tests/unit.sh index 7372e6b..4cb94b8 100755 --- a/tests/unit.sh +++ b/tests/unit.sh @@ -114,6 +114,26 @@ test_filter_json_args() { } } +test_filter_json_pipe() { + # Test for issue #16. + + local out + local json='[{"name": "Foo"}]' + local expected_out='Foo' + + printf '%s\n' "$json" | $SCRIPT _filter_json '.[] | .["name"]' | { + read -r out + + if [ "$expected_out" = "$out" ] ; then + return 0 + else + printf 'Expected output does not match output: `%s` != `%s`\n' \ + "$expected_out" "$out" + return 1 + fi + } +} + test_response_headers() { # Test that process response outputs headers in deterministic order.