Allow creating and updating tasks on the backend. (#2)
Create hurl tests along with the necessary api code to resolve them. Reviewed-on: #2 Co-authored-by: Drew Galbraith <drew@tiramisu.one> Co-committed-by: Drew Galbraith <drew@tiramisu.one>
This commit is contained in:
parent
82d524a62f
commit
d32f6be813
10 changed files with 306 additions and 28 deletions
94
backend/tests/api/tasks.hurl
Normal file
94
backend/tests/api/tasks.hurl
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
# Task API Tests
|
||||
|
||||
# Test: Create a new task (POST /api/tasks)
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Test task",
|
||||
"description": "A test task for the API"
|
||||
}
|
||||
|
||||
HTTP 201
|
||||
[Captures]
|
||||
task_id: jsonpath "$.id"
|
||||
[Asserts]
|
||||
jsonpath "$.title" == "Test task"
|
||||
jsonpath "$.description" == "A test task for the API"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.id" exists
|
||||
jsonpath "$.created_at" exists
|
||||
jsonpath "$.updated_at" exists
|
||||
|
||||
# Test: Create a minimal task (only required fields)
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Minimal task"
|
||||
}
|
||||
|
||||
HTTP 201
|
||||
[Captures]
|
||||
minimal_task_id: jsonpath "$.id"
|
||||
[Asserts]
|
||||
jsonpath "$.title" == "Minimal task"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.description" == null
|
||||
|
||||
# Test: Create task with invalid data (missing title)
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"description": "Task without title"
|
||||
}
|
||||
|
||||
HTTP 422
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Create task with invalid priority
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Invalid priority task",
|
||||
"priority": "This field does not exist."
|
||||
}
|
||||
|
||||
HTTP 422
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Get a specific task by ID (GET /api/tasks/{id})
|
||||
GET {{host}}/api/tasks/{{task_id}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.title" == "Test task"
|
||||
jsonpath "$.description" == "A test task for the API"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.created_at" exists
|
||||
jsonpath "$.updated_at" exists
|
||||
|
||||
# Test: Get a minimal task by ID
|
||||
GET {{host}}/api/tasks/{{minimal_task_id}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{minimal_task_id}}"
|
||||
jsonpath "$.title" == "Minimal task"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.description" == null
|
||||
|
||||
# Test: Get non-existent task
|
||||
GET {{host}}/api/tasks/00000000-0000-0000-0000-000000000000
|
||||
|
||||
HTTP 404
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Get task with invalid UUID format
|
||||
GET {{host}}/api/tasks/invalid-uuid
|
||||
|
||||
HTTP 400
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
Loading…
Add table
Add a link
Reference in a new issue