Commit 2261582d authored by Vincent Pelletier's avatar Vincent Pelletier

shell: Add (minimal) tests.

parent a36ccf92
......@@ -1109,5 +1109,49 @@ EOF
fi
fi
}
_main "$@"
_test() {
# shellcheck disable=SC2039
local netloc="$1" \
tmp_dir \
caucased_dir \
caucased_pid
echo 'Automated testing...'
if command -v caucased > /dev/null; then
:
else
echo 'caucased not found in PATH, cannot run tests' >&2
return 1
fi
tmp_dir="$(mktemp -d --suffix=caucase_sh)"
caucased_dir="$tmp_dir/caucased"
caucased --db "$caucased_dir/db.sqlite" --netloc "$netloc" &
caucased_pid="$!"
trap "kill \"$caucased_pid\"; wait; rm -rf \"$tmp_dir\"" EXIT
if cd "$tmp_dir"; then
:
else
echo 'Could not setup temporary directory'
fi
_main --ca-url "http://$netloc" --update-user
if [ -r cas.crt.pem ]; then
echo 'cas.crt.pem not created'
return 1
fi
if [ -r cau.crt.pem ]; then
echo 'cau.crt.pem not created'
return 1
fi
}
if [ "$#" -gt 0 ] && [ "x$1" = 'x--test' ]; then
if [ "$#" -eq 1 ]; then
_test "localhost:8000"
elif [ "$#" -eq 2 ]; then
_test "$2"
else
echo 'Usage: --test [<hostname/address>:<port>]'
return 1
fi
else
_main "$@"
fi
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment