forked from exercism/sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-result.jq
More file actions
26 lines (23 loc) · 810 Bytes
/
test-result.jq
File metadata and controls
26 lines (23 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def columns:
if (. | length) == 0 then []
else .[0] | keys
end;
def rows:
map(to_entries | map(.value));
def failure_message(got; expected):
(got | columns | tostring) as $got_columns
| (expected | columns | tostring) as $expected_columns
| if $got_columns != $expected_columns then
"Expected columns \($expected_columns); but got \($got_columns)"
else
(got | rows | tostring) as $got_rows
| (expected | rows | tostring) as $expected_rows
| "With columns \($got_columns)\nexpected \($expected_rows)\nbut got \($got_rows)"
end;
$test_data[0][$slug]
| del(.expected) as $entry
| if $got != .expected then
$entry + {"status": "fail", "message": failure_message($got; .expected)}
else
$entry + {"status": "pass"}
end