Task
Create gleam-bookshelf/test/handlers_test.gleam and gleam-bookshelf/test/test_helpers.gleam.
Test cases (same 8 as Go and TS)
- create book — POST /books → 201, check title/author/status/id
- get books — GET /books → 200, non-empty list
- get book — GET /books/:id → 200, check fields present
- get book not found — GET /books/99999 → 404
- update book — PUT /books/:id → 200, check status changed
- delete book — DELETE /books/:id → 204
- create book no title — POST /books → 400
- create book invalid status — POST /books → 400
Test helpers needed
setup() -> Context — connect to Postgres, return context
send_request(method, path, body, ctx) -> Response — send request through router
send_and_expect(method, path, body, expected_status, ctx) -> Response
Key differences from Go/TS
- Uses
gleeunit or startest for test framework
- No
TestMain or beforeAll — setup function called explicitly
- Assertions:
should.equal(value, expected) pattern
- Like TS version, capture
bookId from create for use in later tests
Acceptance criteria
Task
Create
gleam-bookshelf/test/handlers_test.gleamandgleam-bookshelf/test/test_helpers.gleam.Test cases (same 8 as Go and TS)
Test helpers needed
setup() -> Context— connect to Postgres, return contextsend_request(method, path, body, ctx) -> Response— send request through routersend_and_expect(method, path, body, expected_status, ctx) -> ResponseKey differences from Go/TS
gleeunitorstartestfor test frameworkTestMainorbeforeAll— setup function called explicitlyshould.equal(value, expected)patternbookIdfrom create for use in later testsAcceptance criteria
gleam testsucceeds withDATABASE_URLset