Skip to content

feat: end-to-end Go HTTP handler with Postgres integration test#127

Merged
tervezo-ai[bot] merged 4 commits intomainfrom
feat/go-http-handler-with-postgres-integration-test-us-311-z5pzw4plhgykbjb6m6a5s6xc
Mar 15, 2026
Merged

feat: end-to-end Go HTTP handler with Postgres integration test#127
tervezo-ai[bot] merged 4 commits intomainfrom
feat/go-http-handler-with-postgres-integration-test-us-311-z5pzw4plhgykbjb6m6a5s6xc

Conversation

@tervezo-ai
Copy link
Copy Markdown
Contributor

@tervezo-ai tervezo-ai bot commented Mar 14, 2026

Summary

Closes #49 (US-311)

  • Go standalone handler (handler.go): In-memory HTTP handler with routing (/health, /users GET/POST, 404), X-App-Name header, JSON error responses, and field validation. Enables unit testing without Postgres.
  • Updated main.go: Dual-mode — standalone (in-memory) when DATABASE_URL is not set, pgx-based when it is. Added Email field to User struct.
  • Rust guest fixture: Added HTTP-level test functions (test-http-get-users, test-http-post-user, test-http-post-invalid-json, test-http-db-unavailable) with Postgres DataRow parser and JSON formatter.
  • 4 new Rust integration tests: Validate HTTP 200/201/400/503 responses through the WarpGrid database proxy shim chain.
  • Fixed test.sh: Build all Go source files (not just main.go), match actual log output for server readiness.

Test Results

Suite Result
Go unit tests (go test) 9/9 pass
Shell integration (test.sh) 8/8 pass
Rust integration (cargo test) 10/10 pass (6 existing + 4 new HTTP-level)
go vet Clean
build.sh --standalone Pass
TinyGo wasip2 Skipped (toolchain not available)

Test plan

  • go test ./... — all 9 unit tests pass
  • go vet ./... — no issues
  • bash test.sh — all 8 integration tests pass
  • bash build.sh --standalone — passes
  • cargo test -p warpgrid-host --test integration_t3_go_http_postgres — all 10 tests pass
  • TinyGo wasip2 compilation (requires TinyGo 0.40+ in CI)

🤖 Generated with Claude Code

nadilas and others added 4 commits March 14, 2026 21:35
- Create handler.go with in-memory user store, request routing
  (/health, /users GET/POST, 404), and response types
- Update User struct with Email field
- Add dual-mode main(): standalone (no DATABASE_URL) vs postgres
- Generate go.sum via go mod tidy
- All 9 unit tests pass, go vet clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add http-response record type to WIT interface
- Add 4 HTTP-level exported functions: test-http-get-users,
  test-http-post-user, test-http-post-invalid-json, test-http-db-unavailable
- Implement Postgres DataRow parser and JSON formatter in guest
- Guest simulates full HTTP handler flow: DB connect → query → JSON response

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 4 HTTP-level integration tests using dynamic Val API:
  - GET /users → 200 with 5 seed users as JSON
  - POST /users → 201 with inserted user as JSON
  - POST with malformed JSON → 400 with error
  - DB unavailable → 503 with service unavailable error
- All 10 integration tests pass (6 existing + 4 new)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Build from directory instead of single main.go file
- Fix server readiness check to match actual log output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tervezo-ai tervezo-ai bot merged commit 96ffdcd into main Mar 15, 2026
3 of 10 checks passed
@tervezo-ai tervezo-ai bot deleted the feat/go-http-handler-with-postgres-integration-test-us-311-z5pzw4plhgykbjb6m6a5s6xc branch March 15, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

US-311: End-to-end Go HTTP handler with Postgres integration test

1 participant