improve testing workflow
Some checks failed
test-backend / test-x86_64 (push) Failing after 13s

This commit is contained in:
ІО-23 Шмуляр Олег 2025-05-25 21:17:30 +03:00
parent c75f55c050
commit 79ef0a093c
3 changed files with 47 additions and 2 deletions

View File

@ -17,3 +17,11 @@ jobs:
- name: Deploy testing environment
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml up -d
- name: Run test requests
shell: sh
run: |
chmod +x tests/backend.sh
tests/backend.sh
- name: Clean up testing environment
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml up -d

View File

@ -1,4 +1,4 @@
FROM alpine:latest
RUN apk --update add git docker docker-compose postgresql
RUN docker pull postgres
RUN --mount=type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock apk --update add git docker docker-compose postgresql
RUN --mount=type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock docker pull postgres

37
tests/backend.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
assert_good_status () {
if [ $? -ne 0 ]; then
exit 1
fi
}
assert_bad_status () {
if [ $? -eq 0 ]; then
exit 1
fi
}
HOST=127.0.0.1
curl -f http://$HOST/movies
assert_good_status
curl -f http://$HOST/passes
assert_good_status
curl -X POST -f http://$HOST/apply_for_pass
assert_bad_status
curl -X POST -f http://$HOST/apply_for_pass \
-H "Content-Type: application/json" \
--data '{"first": "Hannah",
"last": "Dirt",
"email": "hannah.dirt@mail.com",
"type": 1,
"price": 50,
"movie_uuid": "742a2542-2b50-11f0-ae4c-f7bedd5fcc88"}'
assert_good_status
curl -f http://$HOST/passes | jq '.result.[0]'
assert_good_status