Create the remaining task api methods on the server. (#3)

Create the remaining task api methods along with hurl tests for each.

Reviewed-on: #3
Co-authored-by: Drew Galbraith <drew@tiramisu.one>
Co-committed-by: Drew Galbraith <drew@tiramisu.one>
This commit is contained in:
Drew 2025-09-20 19:23:19 +00:00 committed by Drew
parent d32f6be813
commit ef247e6e29
5 changed files with 457 additions and 3 deletions

View file

@ -0,0 +1,143 @@
# Task List API Tests
# Test: Get task list (may or may not be empty)
GET {{host}}/api/tasks
HTTP 200
[Captures]
initial_count: jsonpath "$" count
[Asserts]
jsonpath "$" isCollection
# Setup: Create multiple tasks with different properties
POST {{host}}/api/tasks
Content-Type: application/json
{
"title": "Test Task Alpha",
"description": "Alpha task description"
}
HTTP 201
[Captures]
alpha_task_id: jsonpath "$.id"
alpha_created_at: jsonpath "$.created_at"
POST {{host}}/api/tasks
Content-Type: application/json
{
"title": "Test Task Beta"
}
HTTP 201
[Captures]
beta_task_id: jsonpath "$.id"
beta_created_at: jsonpath "$.created_at"
POST {{host}}/api/tasks
Content-Type: application/json
{
"title": "Test Task Gamma",
"description": "Gamma task with description"
}
HTTP 201
[Captures]
gamma_task_id: jsonpath "$.id"
gamma_created_at: jsonpath "$.created_at"
# Test: List includes our newly created tasks
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$" isCollection
jsonpath "$" count >= {{initial_count}}
jsonpath "$[*].id" includes "{{alpha_task_id}}"
jsonpath "$[*].id" includes "{{beta_task_id}}"
jsonpath "$[*].id" includes "{{gamma_task_id}}"
jsonpath "$[*].title" includes "Test Task Alpha"
jsonpath "$[*].title" includes "Test Task Beta"
jsonpath "$[*].title" includes "Test Task Gamma"
# Test: Verify all tasks have required fields
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$[?(@.id=='{{alpha_task_id}}')].title" exists
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" exists
jsonpath "$[?(@.id=='{{alpha_task_id}}')].created_at" exists
jsonpath "$[?(@.id=='{{alpha_task_id}}')].updated_at" exists
jsonpath "$[?(@.id=='{{beta_task_id}}')].title" exists
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" exists
jsonpath "$[?(@.id=='{{beta_task_id}}')].created_at" exists
jsonpath "$[?(@.id=='{{beta_task_id}}')].updated_at" exists
# Test: Verify our tasks have correct initial values
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$[?(@.id=='{{alpha_task_id}}')].title" nth 0 == "Test Task Alpha"
jsonpath "$[?(@.id=='{{alpha_task_id}}')].description" nth 0 == "Alpha task description"
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" nth 0 == "todo"
jsonpath "$[?(@.id=='{{beta_task_id}}')].title" nth 0 == "Test Task Beta"
jsonpath "$[?(@.id=='{{beta_task_id}}')].description" nth 0 == null
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" nth 0 == "todo"
# Setup: Update tasks to test mixed statuses
PUT {{host}}/api/tasks/{{beta_task_id}}
Content-Type: application/json
{
"status": "done"
}
HTTP 200
PUT {{host}}/api/tasks/{{gamma_task_id}}
Content-Type: application/json
{
"status": "backlog"
}
HTTP 200
# Test: List shows updated statuses
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" nth 0 == "todo"
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" nth 0 == "done"
jsonpath "$[?(@.id=='{{gamma_task_id}}')].status" nth 0 == "backlog"
# Setup: Delete one task
DELETE {{host}}/api/tasks/{{alpha_task_id}}
HTTP 204
# Test: Deleted task no longer appears in list
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$[*].id" not includes "{{alpha_task_id}}"
jsonpath "$[*].id" includes "{{beta_task_id}}"
jsonpath "$[*].id" includes "{{gamma_task_id}}"
# Cleanup: Delete remaining test tasks
DELETE {{host}}/api/tasks/{{beta_task_id}}
HTTP 204
DELETE {{host}}/api/tasks/{{gamma_task_id}}
HTTP 204
# Test: Our test tasks are gone
GET {{host}}/api/tasks
HTTP 200
[Asserts]
jsonpath "$[*].id" not includes "{{beta_task_id}}"
jsonpath "$[*].id" not includes "{{gamma_task_id}}"