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 | |
parent | workflows/ci: rearrange dependencies (diff) | |
download | cgitize-46ae7860d41664cdd97263e97e1023a0f9fa269f.tar.gz cgitize-46ae7860d41664cdd97263e97e1023a0f9fa269f.zip |
t/i/docker: test the frontend also
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/docker/docker-compose.yml | 6 | ||||
-rwxr-xr-x | test/integration/docker/test.sh | 71 |
2 files changed, 76 insertions, 1 deletions
diff --git a/test/integration/docker/docker-compose.yml b/test/integration/docker/docker-compose.yml index 1a5acf6..3a00971 100644 --- a/test/integration/docker/docker-compose.yml +++ b/test/integration/docker/docker-compose.yml @@ -14,3 +14,9 @@ services: - ./cgitize/etc:/etc/cgitize:ro - "$SSH_AUTH_SOCK:/ssh-agent.sock" - ./cgitize/output:/mnt/cgitize + frontend: + extends: + file: ../../../docker-compose.yml + service: frontend + volumes: + - ./cgitize/output:/mnt/cgitize:ro 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 |