2019-09-20 21:44:51 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-09-21 20:43:17 +00:00
|
|
|
source "${SCRIPT_DIR}/src/main.sh"
|
2019-09-20 21:44:51 +00:00
|
|
|
|
2019-09-23 20:46:16 +00:00
|
|
|
OPTIONS="$(opts::eval "$@")"
|
|
|
|
export NAVI_PATH="$(dict::get "$OPTIONS" path)"
|
|
|
|
|
2019-09-23 11:56:15 +00:00
|
|
|
PASSED=0
|
|
|
|
FAILED=0
|
|
|
|
|
2019-09-20 21:44:51 +00:00
|
|
|
test::success() {
|
2019-09-23 11:56:15 +00:00
|
|
|
PASSED=$((PASSED+1))
|
2019-09-20 23:08:13 +00:00
|
|
|
echo "Test passed!"
|
2019-09-20 21:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::fail() {
|
2019-09-23 11:56:15 +00:00
|
|
|
FAILED=$((FAILED+1))
|
2019-09-20 23:08:13 +00:00
|
|
|
echo "Test failed..."
|
2019-09-23 11:56:15 +00:00
|
|
|
return
|
2019-09-21 22:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::run() {
|
2019-09-21 22:24:09 +00:00
|
|
|
echo
|
|
|
|
echo "-> $1"
|
|
|
|
shift
|
|
|
|
eval "$*" && test::success || test::fail
|
2019-09-23 11:56:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-23 20:46:16 +00:00
|
|
|
test::equals() {
|
|
|
|
local -r actual="$(cat | tr -d '\n')"
|
|
|
|
local -r expected="$(echo "${1:-}" | tr -d '\n' | sed 's/\\n//g')"
|
|
|
|
|
|
|
|
if [[ "$actual" != "$expected" ]]; then
|
|
|
|
echo "Expected '${expected}' but got '${actual}'"
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-09-23 11:56:15 +00:00
|
|
|
test::finish() {
|
|
|
|
echo
|
|
|
|
if [ $FAILED -gt 0 ]; then
|
|
|
|
echo "${PASSED} tests passed but ${FAILED} failed... :("
|
|
|
|
exit "${FAILED}"
|
|
|
|
else
|
|
|
|
echo "All ${PASSED} tests passed! :)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|