Fixed acceptance tests

This commit is contained in:
Mike Farah 2021-10-30 14:00:28 +11:00
parent 08fc058934
commit d4b9781ee6

View File

@ -1,46 +1,36 @@
#!/bin/bash #!/bin/bash
tearDown() {
set -e
}
testWriteInPlacePipeIn() { testWriteInPlacePipeIn() {
set +e
result=$(./yq e -i -n '.a' 2>&1) result=$(./yq e -i -n '.a' 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result" assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result"
} }
testWriteInPlacePipeInEvalall() { testWriteInPlacePipeInEvalall() {
set +e
result=$(./yq ea -i -n '.a' 2>&1) result=$(./yq ea -i -n '.a' 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result" assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result"
} }
testWriteInPlaceWithSplit() { testWriteInPlaceWithSplit() {
set +e
result=$(./yq e -s "cat" -i '.a = "thing"' test.yml 2>&1) result=$(./yq e -s "cat" -i '.a = "thing"' test.yml 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: write inplace cannot be used with split file" "$result" assertEquals "Error: write inplace cannot be used with split file" "$result"
} }
testWriteInPlaceWithSplitEvalAll() { testWriteInPlaceWithSplitEvalAll() {
set +e
result=$(./yq ea -s "cat" -i '.a = "thing"' test.yml 2>&1) result=$(./yq ea -s "cat" -i '.a = "thing"' test.yml 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: write inplace cannot be used with split file" "$result" assertEquals "Error: write inplace cannot be used with split file" "$result"
} }
testNullWithFiles() { testNullWithFiles() {
set +e
result=$(./yq e -n '.a = "thing"' test.yml 2>&1) result=$(./yq e -n '.a = "thing"' test.yml 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: cannot pass files in when using null-input flag" "$result" assertEquals "Error: cannot pass files in when using null-input flag" "$result"
} }
testNullWithFilesEvalAll() { testNullWithFilesEvalAll() {
set +e
result=$(./yq ea -n '.a = "thing"' test.yml 2>&1) result=$(./yq ea -n '.a = "thing"' test.yml 2>&1)
assertEquals 1 $? assertEquals 1 $?
assertEquals "Error: cannot pass files in when using null-input flag" "$result" assertEquals "Error: cannot pass files in when using null-input flag" "$result"