40 lines
1.4 KiB
Bash
Executable File
40 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
BASE_URL="${BASE_URL:-http://localhost:8000}"
|
|
URL="$BASE_URL/links"
|
|
|
|
echo "== POST /links (création) =="
|
|
curl -s -w "\n[%{http_code}]\n" -X POST "$URL" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"title":"Titre vidéo","description":"Description","link_url":"https://youtube.com/watch?v=aaa","thumbnail":"https://img.youtube.com/vi/aaa/default.jpg"}'
|
|
|
|
echo "== GET /links (liste) =="
|
|
curl -s -w "\n[%{http_code}]\n" "$URL"
|
|
|
|
echo "== GET /links/1 (lecture) =="
|
|
curl -s -w "\n[%{http_code}]\n" "$URL/1"
|
|
|
|
echo "== PUT /links/1 (modification) =="
|
|
curl -s -w "\n[%{http_code}]\n" -X PUT "$URL/1" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"title":"Titre modifié","description":"Nouvelle description","link_url":"https://youtube.com/watch?v=aaa"}'
|
|
|
|
echo "== POST /links (URL invalide -> 422) =="
|
|
curl -s -w "\n[%{http_code}]\n" -X POST "$URL" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"title":"X","link_url":"pas-une-url"}'
|
|
|
|
echo "== POST /links (URL dupliquée -> 409) =="
|
|
curl -s -w "\n[%{http_code}]\n" -X POST "$URL" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"title":"Doublon","link_url":"https://youtube.com/watch?v=aaa"}'
|
|
|
|
echo "== GET /links/999 (introuvable -> 404) =="
|
|
curl -s -w "\n[%{http_code}]\n" "$URL/999"
|
|
|
|
echo "== DELETE /links/1 (suppression) =="
|
|
curl -s -w "\n[%{http_code}]\n" -X DELETE "$URL/1"
|
|
|
|
echo "== data.json =="
|
|
cat data/data.json |