From 4c2de4c364edb86afed41fdba33f3816a1794945 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 16 Nov 2021 16:08:37 +1100 Subject: [PATCH] Load file acceptance test --- acceptance_tests/load-file.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/acceptance_tests/load-file.sh b/acceptance_tests/load-file.sh index 9fd00661..48ebb6c8 100755 --- a/acceptance_tests/load-file.sh +++ b/acceptance_tests/load-file.sh @@ -1,11 +1,27 @@ #!/bin/bash -setUp() { - rm test*.yml || true +testLoadFileNotExist() { + result=$(./yq e -n 'load("cat.yml")' 2>&1) + assertEquals 1 $? + assertEquals "Error: Failed to load cat.yml: open cat.yml: no such file or directory" "$result" } -testLoadFileNotExist() { +testLoadFileExpNotExist() { + result=$(./yq e -n 'load(.a)' 2>&1) + assertEquals 1 $? + assertEquals "Error: Filename expression returned nil" "$result" } testStrLoadFileNotExist() { -} \ No newline at end of file + result=$(./yq e -n 'strload("cat.yml")' 2>&1) + assertEquals 1 $? + assertEquals "Error: Failed to load cat.yml: open cat.yml: no such file or directory" "$result" +} + +testStrLoadFileExpNotExist() { + result=$(./yq e -n 'strload(.a)' 2>&1) + assertEquals 1 $? + assertEquals "Error: Filename expression returned nil" "$result" +} + +source ./scripts/shunit2 \ No newline at end of file