diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-12-03 22:49:08 +0100 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-12-03 22:49:08 +0100 |
commit | 46ae7860d41664cdd97263e97e1023a0f9fa269f (patch) | |
tree | 15cbf410cb1cab09889faeca74b846cf346bb754 /test/integration/docker/test.sh | |
parent | workflows/ci: rearrange dependencies (diff) | |
download | cgitize-46ae7860d41664cdd97263e97e1023a0f9fa269f.tar.gz cgitize-46ae7860d41664cdd97263e97e1023a0f9fa269f.zip |
t/i/docker: test the frontend also
Diffstat (limited to '')
-rwxr-xr-x | test/integration/docker/test.sh | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/test/integration/docker/test.sh b/test/integration/docker/test.sh index e39cf84..fd21ec8 100755 --- a/test/integration/docker/test.sh +++ b/test/integration/docker/test.sh @@ -12,6 +12,7 @@ readonly script_name readonly ssh_dir="$script_dir/ssh" readonly client_key_password='password' readonly output_dir="$script_dir/cgitize/output" +readonly frontend_host=localhost dump() { local prefix="${FUNCNAME[0]}" @@ -44,6 +45,43 @@ cleanup() { popd > /dev/null } +_curl() { + local -a opts=(curl -sS --connect-timeout 5) + opts+=("$@") + + printf -- '%q ' ${opts[@]+"${opts[@]}"} >&2 + printf '\n' >&2 + + ${opts[@]+"${opts[@]}"} +} + +curl_document() { + _curl -L "$@" +} + +curl_status_code() { + _curl -o /dev/null -w '%{http_code}\n' "$@" +} + +curl_check_code() { + if [ "$#" -lt 1 ]; then + echo "usage: ${FUNCNAME[0]} EXPECTED [CURL_ARG...]" >&2 + return 1 + fi + + local expected + expected="$1" + shift + + local actual + actual="$( curl_status_code "$@" )" + + if [ "$expected" != "$actual" ]; then + echo "Expected code: $expected, actual code: $actual" >&2 + return 1 + fi +} + generate_ssh_keys() { echo echo ---------------------------------------------------------------------- @@ -152,12 +190,23 @@ run_cgitize() { docker-compose run --rm cgitize } +run_frontend() { + echo + echo ---------------------------------------------------------------------- + echo Running the frontend + echo ---------------------------------------------------------------------- + + docker-compose up -d frontend + sleep 2 +} + run() { run_git_server run_cgitize + run_frontend } -verify() { +verify_git() { echo echo ---------------------------------------------------------------------- echo Checking the pulled repository @@ -168,6 +217,26 @@ verify() { popd > /dev/null } +verify_frontend() { + echo + echo ---------------------------------------------------------------------- + echo Checking the frontend + echo ---------------------------------------------------------------------- + + local output + + output="$( curl_document "http://$frontend_host/test_repo/" )" + echo "$output" | grep -o -F -- "<meta name='generator' content='cgit " + + curl_check_code 200 "http://$frontend_host/test_repo/" + curl_check_code 200 "http://$frontend_host/test_repo/tree/" +} + +verify() { + verify_git + verify_frontend +} + main() { pushd -- "$script_dir" > /dev/null trap cleanup EXIT |