Create hurl tests for task creation and retrieval
This commit is contained in:
parent
82d524a62f
commit
20ee812393
2 changed files with 132 additions and 0 deletions
117
backend/tests/api/tasks.hurl
Normal file
117
backend/tests/api/tasks.hurl
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# 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",
|
||||
"priority": "medium",
|
||||
"due_date": "2024-12-31",
|
||||
"status": "todo"
|
||||
}
|
||||
|
||||
HTTP 201
|
||||
[Captures]
|
||||
task_id: jsonpath "$.id"
|
||||
[Asserts]
|
||||
jsonpath "$.title" == "Test task"
|
||||
jsonpath "$.description" == "A test task for the API"
|
||||
jsonpath "$.priority" == "medium"
|
||||
jsonpath "$.due_date" == "2024-12-31"
|
||||
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 "$.priority" == "medium"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.description" == null
|
||||
jsonpath "$.due_date" == null
|
||||
|
||||
# Test: Create task with invalid data (missing title)
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"description": "Task without title"
|
||||
}
|
||||
|
||||
HTTP 400
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Create task with invalid priority
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Invalid priority task",
|
||||
"priority": "invalid"
|
||||
}
|
||||
|
||||
HTTP 400
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Create task with invalid status
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Invalid status task",
|
||||
"status": "invalid"
|
||||
}
|
||||
|
||||
HTTP 400
|
||||
[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 "$.priority" == "medium"
|
||||
jsonpath "$.due_date" == "2024-12-31"
|
||||
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 "$.priority" == "medium"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.description" == null
|
||||
jsonpath "$.due_date" == 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