Open jadutter opened 4 months ago
I've thought about some kind of binding support in the .test format, either inline or read from a file. Could that be an alternative?
Can't come up with a neat syntax now but something like this:
# read json value inline
%%BIND $input
{
"a": 123
}
.a
$input
123
type
$input
"object"
# read json value from file.json
%%BIND $input file.json
...
Doh i got it wrong, probably more like:
# read json value inline
%%BIND $input
{
"a": 123
}
$input | .a
null
123
$input | type
null
"object"
Fixed it so that
jq
can use--slurpfile
and--rawfile
when running tests. I think it's useful to be able to reference a file containing some data instead of needing to repeatedly copy-paste the same input to different test cases. Particularly since if the input is a larger object, then it's difficult to read since it needs to be all on one line in the test file.Simple example
Given the following files
raw.csv
slurp.json
and this test file
myjq.test
then this command
should output