Files
bpfire/tests/src/initscripts/system/functions/test2.sh
Jonatan Schlag dae8a08086 tests/lib.sh: Add function test_value_in_array
Test if a given array has the specified value stored under key.

! does not work here to access the array by variable name. So the solution here is:
https://unix.stackexchange.com/questions/60584/how-to-use-a-variable-as-part-of-an-array-name/60585#60585

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-08-24 12:19:56 +00:00

22 lines
643 B
Bash
Executable File

#!/usr/bin/bash
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
ROOT="$(readlink -f "${SCRIPT_PATH}/../../../../..")"
. ${ROOT}/tests/lib.sh
. ${ROOT}/src/initscripts/system/functions
# read the date in
readhash "CONFIG" "${SCRIPT_PATH}/data/1"
# test if we read the correct data
test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire"
test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3"
test_that_output_is "${SCRIPT_PATH}/data/1_output_stdout" "1" readhash "CONFIG" "${SCRIPT_PATH}/data/1"
test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" "${SCRIPT_PATH}/data/1"