diff --git a/scripts/acceptance.sh b/scripts/acceptance.sh index d6981033..f41a288e 100755 --- a/scripts/acceptance.sh +++ b/scripts/acceptance.sh @@ -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"