eeaad62b10
- internal/postgres: pgx-over-database/sql pool (otelsql), embedded goose
migrations into schema 'backend', committed go-jet code + cmd/jetgen tool.
- internal/account: durable accounts + unified telegram/email identities
(UUIDv7 keys), find-or-create provisioning with unique-conflict handling.
- internal/session: opaque 256-bit tokens stored as a SHA-256 hash, revoke-only
(no TTL); write-through cache gating /readyz; store + service.
- internal/telemetry: OTel tracer/meter providers (none/stdout) + request-timing
middleware; internal/config gains Postgres + OTel env loading.
- internal/server: /api/v1 {public,user,internal,admin} skeleton + X-User-ID
middleware; /readyz checks DB ping + cache; main wires
telemetry -> db+migrate -> warm cache -> server.
- Tests: unit + integration (build tag 'integration', testcontainers
postgres:17) for migrations, accounts, sessions, readyz; new integration.yaml.
- Docs: ARCHITECTURE, TESTING, PLAN refinements, root + backend READMEs.
Session/account REST handlers deferred to Stage 6 (gateway); OTLP + dashboards
to Stage 11.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
//go:build integration
|
|
|
|
package inttest
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
"scrabble/backend/internal/server"
|
|
"scrabble/backend/internal/session"
|
|
)
|
|
|
|
// TestReadyzWithRealDatabase exercises the assembled server against the live
|
|
// container: /readyz answers 200 once the database pings and the session cache
|
|
// is warmed, closing the gap the unit test (nil database) cannot cover.
|
|
func TestReadyzWithRealDatabase(t *testing.T) {
|
|
svc := session.NewService(session.NewStore(testDB), session.NewCache())
|
|
if err := svc.Warm(context.Background()); err != nil {
|
|
t.Fatalf("warm session cache: %v", err)
|
|
}
|
|
|
|
srv := server.New(":0", server.Deps{
|
|
Logger: zaptest.NewLogger(t),
|
|
DB: testDB,
|
|
PingTimeout: 5 * time.Second,
|
|
SessionsReady: svc.Ready,
|
|
})
|
|
|
|
for _, path := range []string{"/healthz", "/readyz"} {
|
|
rec := httptest.NewRecorder()
|
|
srv.Handler().ServeHTTP(rec, httptest.NewRequest(http.MethodGet, path, nil))
|
|
if rec.Code != http.StatusOK {
|
|
t.Errorf("%s status = %d, want 200", path, rec.Code)
|
|
}
|
|
}
|
|
}
|