Skip to content

Implement Update Todo endpoint (PATCH /todos/:id) #7

@landoyjx

Description

@landoyjx

Implement PATCH /todos/:id to partially update a Todo. Accept optional fields title (string, non-empty) and completed (boolean). Response should be 200 OK with the updated Todo object, or 404 Not Found if the id does not exist. updatedAt should be refreshed on every successful update.

Acceptance Criteria:

  • Updating only title changes title and updatedAt
  • Updating only completed changes completed and updatedAt
  • Updating both fields changes both and updatedAt
  • Returns 404 for non-existent id
  • Returns 400 if title is provided as empty string

Test Cases:

  • Integration: PATCH /todos/:id { "title": "New title" } returns updated Todo with new title and updated updatedAt
  • Integration: PATCH /todos/:id { "completed": true } returns updated Todo with completed=true
  • Integration: PATCH /todos/:id { "title": "A", "completed": false } returns updated Todo
  • Integration: PATCH /todos/:id with non-existent id returns 404
  • Integration: PATCH /todos/:id { "title": "" } returns 400
  • Edge: PATCH /todos/:id with {} returns 200 and Todo unchanged (or 400 depending on strictness; document behavior)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions