-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·37 lines (29 loc) · 925 Bytes
/
test.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
#!/bin/sh
PORT=12345
for item in 0 1 2 3 4 5 6 7
do
curl -d "Note $item" -H "Content-Type: text/plain" -X POST http://localhost:${PORT}/notes 1>/dev/null 2>/dev/null
if test $? -ne 0; then
echo "Veuillez démarrer le serveur Express avant ce script."
exit 1
fi
done
echo "Get all notes"
curl -X GET http://localhost:${PORT}/notes
echo
echo "Get one note"
curl -X GET http://localhost:${PORT}/notes/1
echo
echo "Get an invalid note"
curl -X GET http://localhost:${PORT}/notes/azer
echo
echo "Delete one note"
curl -X DELETE http://localhost:${PORT}/notes/0
echo
echo "Attest the deleted note is gone"
curl -X GET http://localhost:${PORT}/notes/0
echo
echo "Add a note with an author"
id=$(curl -s -X POST -H "Content-Type: application/json" -d "{\"data\":\"Note $item\", \"author\":\"Sylvain\"}" http://localhost:${PORT}/notes-details)
curl -X GET http://localhost:${PORT}/notes/${id}
echo