make cleanup happen even if workflow fails
Some checks failed
test-backend / test-x86_64 (push) Has been cancelled

This commit is contained in:
ІО-23 Шмуляр Олег 2025-05-25 21:23:29 +03:00
parent 79ef0a093c
commit 0d519ec14f
3 changed files with 24 additions and 6 deletions

View File

@ -17,11 +17,18 @@ jobs:
- name: Deploy testing environment
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml up -d
- name: Add tables to DB
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml exec -T postgres psql -U postgres < backend/db/create.sql
- name: Populate DB
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml exec -T postgres psql -U postgres < backend/db/populate.sql
- name: Run test requests
shell: sh
run: |
chmod +x tests/backend.sh
tests/backend.sh
- name: Clean up testing environment
if: always()
shell: sh
run: docker-compose -f backend/docker-compose-x86_64.yaml up -d
run: docker-compose -f backend/docker-compose-x86_64.yaml down

7
backend/db/populate.sql Normal file
View File

@ -0,0 +1,7 @@
INSERT INTO public.movie (uuid, name, scheduled_datetime, movie_details, image_url, max_passes)
VALUES ('742a2542-2b50-11f0-ae4c-f7bedd5fcc88',
'Movie 1',
'1997-12-15 21:30:00',
'This movie dives deep into many topics...',
'https://cdn.cinema.com/img/movie1.webp',
150);

View File

@ -13,17 +13,18 @@ assert_bad_status () {
}
HOST=127.0.0.1
ARGS="--fail-with-body"
curl -f http://$HOST/movies
curl $ARGS http://$HOST/movies
assert_good_status
curl -f http://$HOST/passes
curl $ARGS http://$HOST/passes
assert_good_status
curl -X POST -f http://$HOST/apply_for_pass
curl -X POST $ARGS http://$HOST/apply_for_pass
assert_bad_status
curl -X POST -f http://$HOST/apply_for_pass \
curl -X POST $ARGS http://$HOST/apply_for_pass \
-H "Content-Type: application/json" \
--data '{"first": "Hannah",
"last": "Dirt",
@ -33,5 +34,8 @@ curl -X POST -f http://$HOST/apply_for_pass \
"movie_uuid": "742a2542-2b50-11f0-ae4c-f7bedd5fcc88"}'
assert_good_status
curl -f http://$HOST/passes | jq '.result.[0]'
sleep 10h
curl $ARGS -s http://$HOST/passes
test [ $(curl $ARGS -s http://$HOST/passes | jq '.result.[0]') != "null" ]
assert_good_status