Skip to content

Commit 2235849

Browse files
committed
Add external script integration
1 parent fffaa8f commit 2235849

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

api-test.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ test_factory() {
230230
}
231231

232232
test_runner() {
233-
for test in ""contains eq path_eq path_contains hasKey[]""; do
233+
for test in ""contains eq path_eq path_contains hasKey[] external""; do
234234
local TEST_SCENARIO=$(jq -r ".testCases.$1.expect.$2.$test? | select(. !=null)" $FILE)
235235
if [[ -z $TEST_SCENARIO ]]; then
236236
continue
@@ -248,13 +248,30 @@ test_runner() {
248248
elif [[ $test == "path_contains" ]]; then
249249
echo "Checking path contains comparision${RESET}"
250250
path_checker "$TEST_SCENARIO" "$3" 1
251+
elif [[ $test == "external" ]]; then
252+
echo "Checking external comparision${RESET}"
253+
external_script "$TEST_SCENARIO" "$3"
251254
else
252255
echo "Checking has key comparision${RESET}"
253256
has_key "$TEST_SCENARIO" "$3"
254257
fi
255258
done
256259
}
257260

261+
external_script() {
262+
$1 "$2"
263+
if [[ $? == 0 ]]; then
264+
tput cuf 6
265+
266+
echo "${GREEN}${BOLD}Check Passed${RESET}"
267+
else
268+
tput cuf 6
269+
270+
echo "${RED}${BOLD}Check Failed${RESET}"
271+
echo "External check returned error"
272+
fi
273+
}
274+
258275
contains() {
259276
tput cuf 6
260277
local check=$(jq -c --argjson a "$1" --argjson b "$2" -n '$a | select(. != null) | $b | contains($a)')

0 commit comments

Comments
 (0)