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.
26 lines
678 B
Go
26 lines
678 B
Go
//go:build integration
|
|
|
|
package inttest
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"scrabble/backend/internal/postgres"
|
|
)
|
|
|
|
// TestApplyMigrationsIdempotent re-applies the migrations against the already
|
|
// migrated database and confirms the expected tables are queryable.
|
|
func TestApplyMigrationsIdempotent(t *testing.T) {
|
|
ctx := context.Background()
|
|
if err := postgres.ApplyMigrations(ctx, testDB); err != nil {
|
|
t.Fatalf("re-apply migrations: %v", err)
|
|
}
|
|
for _, table := range []string{"accounts", "identities", "sessions"} {
|
|
var n int
|
|
if err := testDB.QueryRowContext(ctx, "SELECT count(*) FROM "+table).Scan(&n); err != nil {
|
|
t.Errorf("count %s: %v", table, err)
|
|
}
|
|
}
|
|
}
|