improved acceptance tests

This commit is contained in:
Mike Farah 2020-12-01 14:14:16 +11:00
parent 08f579f4e3
commit cf4915d786

View File

@ -3,10 +3,47 @@
set -e
# acceptance test
X=$(./yq e '.b.c |= 3' ./examples/sample.yaml | ./yq e '.b.c' -)
if [[ $X != 3 ]]; then
echo "Failed acceptance test: expected 3 but was $X"
random=$((1 + $RANDOM % 10))
./yq e -n ".a = $random" > test.yml
X=$(./yq e '.a' test.yml)
if [[ $X != $random ]]; then
echo "Failed create: expected $random but was $X"
exit 1
fi
echo "created yaml successfully"
update=$(($random + 1))
./yq e -i ".a = $update" test.yml
X=$(./yq e '.a' test.yml)
if [[ $X != $update ]]; then
echo "Failed to update inplace test: expected $update but was $X"
exit 1
fi
echo "updated in place successfully"
X=$(./yq e '.z' test.yml)
echo "no exit status success"
set +e
X=$(./yq e -e '.z' test.yml)
if [[ $? != 1 ]]; then
echo "Expected error code 1 but was $?"
exit 1
fi
echo "exit status success"
set -e
rm test.yml
echo "acceptance tests passed"