Skip to content

gleam: write integration tests (same 8 cases as Go/TS) #12

@HeyItWorked

Description

@HeyItWorked

Task

Create gleam-bookshelf/test/handlers_test.gleam and gleam-bookshelf/test/test_helpers.gleam.

Test cases (same 8 as Go and TS)

  1. create book — POST /books → 201, check title/author/status/id
  2. get books — GET /books → 200, non-empty list
  3. get book — GET /books/:id → 200, check fields present
  4. get book not found — GET /books/99999 → 404
  5. update book — PUT /books/:id → 200, check status changed
  6. delete book — DELETE /books/:id → 204
  7. create book no title — POST /books → 400
  8. 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

  • All 8 test cases pass against real Postgres (no mocks)
  • gleam test succeeds with DATABASE_URL set

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgleamGleam implementation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions