Because the whitespace that is printed by jq when outputting arrays
and objects in non-compact notation does not match the whitespace
that is expected by the test cases, the tests fail.
This commit modifies the `json_array_to_lines()' function so that it
outputs data in compact JSON notation, and changes the test cases so
they do not expect any whitespace at all.
json_array_to_lines() {
local array="$1"
- if ! jq -r '.[]' <<< "$array"; then
+ if ! jq -c -r '.[]' <<< "$array"; then
return 1
fi
End
It "splits an object array to lines"
- When call json_array_to_lines '[{"data": 1}, {"data": 2}]'
- The first line of stdout should equal '{"data": 1}'
- The second line of stdout should equal '{"data": 2}'
+ When call json_array_to_lines '[{"data":1}, {"data":2}]'
+ The first line of stdout should equal '{"data":1}'
+ The second line of stdout should equal '{"data":2}'
The status should equal 0
End
End