-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.sh
executable file
·46 lines (38 loc) · 885 Bytes
/
test.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bats
function query-json () {
if [[ -n $IS_CI ]]; then
echo "Running in CI mode"
run ./query-json "$@"
else
chmod +x _build/default/bin/Bin.exe
run "_build/default/bin/Bin.exe" "$@"
fi
}
@test "json call works ok" {
query-json --no-color '.first.name' e2e/mock.json
[ "$status" -eq 0 ]
[ "$output" = '"John Doe"' ]
}
@test "inline call works ok" {
query-json --no-color --kind=inline '.' '{ "a": 1 }'
[ "$status" -eq 0 ]
[ "$output" = '{ "a": 1 }' ]
}
# Can't test stdin on bash :(
# @test "stdin works ok" {
# cat e2e/mock.json | query-json '.first.name'
# [ "$status" -eq 0 ]
# [ "$output" = '"John Doe"' ]
# }
@test "non defined field gives back null" {
query-json --no-color '.wat?' e2e/mock.json
[ "$status" -eq 0 ]
[ "$output" = "null" ]
}
teardown () {
echo "$BATS_TEST_NAME
--------
$output
--------
"
}