-
Notifications
You must be signed in to change notification settings - Fork 0
/
testEndpoints.sh
39 lines (32 loc) · 1.1 KB
/
testEndpoints.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
BASE_URL="http://localhost:3000"
# View all mangas
echo "All mangas:"
curl -X GET "${BASE_URL}/mangas"
echo -e "\n"
# View manga with id of 2
echo "Manga with id of 2:"
curl -X GET "${BASE_URL}/mangas/2"
echo -e "\n"
# Create new manga
echo "Create new manga:"
curl -X POST "${BASE_URL}/mangas" -H "Content-Type: application/json" -d '{
"name": "Baka and Test",
"author": "Kenji Inoue",
"date_published": "2007-01-29",
"description": "The students of Fumizuki Academy are rigidly divided by their test scores, and battle between classes using Summoned Beasts to win better facilities and benefits."}'
echo -e "\n"
# Update newly created manga
echo "Update existing manga"
curl -X PATCH "${BASE_URL}/mangas/11" -H "Content-Type: application/json" -d '{
"name": "Baka and Test",
"description": "Updated description"}'
echo -e "\n"
# Delete newly created manga
echo "Deleting existing manga:"
curl -X DELETE "${BASE_URL}/mangas/11"
echo -e "\n"
echo "Finished"
echo -e "\n"
echo "To re-run testEndpoints.sh the database needs to be re-seeded"
echo "cd server"
echo "npm run seed-db"