feat: end-to-end Go HTTP handler with Postgres integration test#127
Merged
tervezo-ai[bot] merged 4 commits intomainfrom Mar 15, 2026
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #49 (US-311)
handler.go): In-memory HTTP handler with routing (/health,/usersGET/POST, 404),X-App-Nameheader, JSON error responses, and field validation. Enables unit testing without Postgres.main.go: Dual-mode — standalone (in-memory) whenDATABASE_URLis not set, pgx-based when it is. AddedEmailfield toUserstruct.test-http-get-users,test-http-post-user,test-http-post-invalid-json,test-http-db-unavailable) with Postgres DataRow parser and JSON formatter.test.sh: Build all Go source files (not justmain.go), match actual log output for server readiness.Test Results
go test)test.sh)cargo test)go vetbuild.sh --standaloneTest plan
go test ./...— all 9 unit tests passgo vet ./...— no issuesbash test.sh— all 8 integration tests passbash build.sh --standalone— passescargo test -p warpgrid-host --test integration_t3_go_http_postgres— all 10 tests pass🤖 Generated with Claude Code