[v2,18/18] initscripts fkt: Check that readhash returns 1 on a missing file

Message ID 20240616160245.18865-19-jonatan.schlag@ipfire.org
State New
Headers
Series [v2,01/18] tests: Add bash lib |

Commit Message

Jonatan Schlag June 16, 2024, 4:02 p.m. UTC
  It already does that, so the function is not changed

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 tests/src/initscripts/system/functions/test.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh
index e7f695f55..dbcbd45ef 100755
--- a/tests/src/initscripts/system/functions/test.sh
+++ b/tests/src/initscripts/system/functions/test.sh
@@ -10,6 +10,7 @@  ROOT="$(readlink -f "${SCRIPT_PATH}/../../../../..")"
 
 # read the date in
 readhash "CONFIG" "${SCRIPT_PATH}/data/1"
+test_command [ $? == 0 ]
 
 # test if we read the correct data
 test_value_in_array "CONFIG" "RED_DHCP_HOSTNAME" "ipfire"
@@ -27,6 +28,8 @@  test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG"
 
 # Check with invalid Lines (values and keys)
 readhash "CONFIG2" "${SCRIPT_PATH}/data/2" &> /dev/null
+test_command [ $? == 0 ]
+
 
 # test if we read the correct data
 test_value_in_array "CONFIG2" "RED_DHCP_HOSTNAME" "ipfire"
@@ -39,4 +42,6 @@  test_value_in_array "CONFIG2" "BLUE_MACADDR" "bc:30:7d:58:6b:e3"
 test_that_output_is "${SCRIPT_PATH}/data/2_output_stdout" "1" readhash "CONFIG2" "${SCRIPT_PATH}/data/2"
 test_that_output_is "${SCRIPT_PATH}/data/2_output_stderr" "2" readhash "CONFIG2" "${SCRIPT_PATH}/data/2"
 
-
+# Check non existent file
+readhash "CONFIG3" "${SCRIPT_PATH}/data/-1" &> /dev/null
+test_command [ $? == 1 ]