sdlc-project/tests/backend.sh

42 lines
768 B
Bash
Raw Normal View History

2025-05-25 21:17:30 +03:00
#!/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
ARGS="--fail-with-body"
2025-05-25 21:17:30 +03:00
curl $ARGS http://$HOST/movies
2025-05-25 21:17:30 +03:00
assert_good_status
curl $ARGS http://$HOST/passes
2025-05-25 21:17:30 +03:00
assert_good_status
curl -X POST $ARGS http://$HOST/apply_for_pass
2025-05-25 21:17:30 +03:00
assert_bad_status
curl -X POST $ARGS http://$HOST/apply_for_pass \
2025-05-25 21:17:30 +03:00
-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
sleep 5
curl $ARGS -s http://$HOST/passes
test [ $(curl $ARGS -s http://$HOST/passes | jq '.result.[0]') != "null" ]
2025-05-25 21:17:30 +03:00
assert_good_status