Testing (internal/tests)
GoForge tests use Go's standard testing package + net/http/httptest and isolated t.TempDir() SQLite databases — zero external assertion frameworks required.
Test Layout
text
core/database/dsn_test.go # DSN escaping & SQLite pragmas
internal/tests/
├── unit/
│ ├── di_test.go # 18 DI container, Bind, AutoCollect & Lifecycle tests
│ ├── events_test.go # Concurrency, shutdown drain, panics, DispatchSync
│ └── config_validator_db_test.go # Config load/validate, validator JSON tags, DB connect
├── http/
│ ├── client_test.go # HttpClient non-mutation & X-App-Key
│ └── middleware_test.go # CORS, AppKey, RateLimiter, Recovery, RequestID, /ready
├── grpc/
│ └── client_test.go # GrpcClient, AppKey unary/stream interceptors, LimiterStore
└── integration/
├── di_integration_test.go # Multi-module boot.NewWithConfig + HTTP + gRPC + events
└── todo_test.go # End-to-end CRUD + context.WithoutCancel audit verificationRunning Tests
bash
go test ./...
go test -race ./...
# Or using the shipped skill script:
bash .agent/skills/testing/run.shCommon Testing Patterns
1. Testing HTTP Middleware & Endpoints
server.NewHTTPServer(cfg, routers, ...).Engine() returns the *gin.Engine directly without binding a TCP port:
go
srv := server.NewHTTPServer(cfg, []server.Router{todoRoutes}, server.WithReadinessCheck(db.Ping))
defer srv.Stop(context.Background())
req := httptest.NewRequest(http.MethodGet, "/ready", nil)
w := httptest.NewRecorder()
srv.Engine().ServeHTTP(w, req)2. Full-Stack Integration Tests with boot.NewWithConfig
Use t.TempDir() for SQLite isolation, boot.NewWithConfig(cfg, modules...) to build the real DI graph, and defer app.Stop(context.Background()) to drain EventBus and close the DB pool:
go
app, err := boot.NewWithConfig(cfg, todo.Module())
if err != nil {
t.Fatal(err)
}
defer func() { _ = app.Stop(context.Background()) }()
db, _ := di.Resolve[*database.Database](app.Container)
gormDB, _ := db.GetGorm()
_ = gormDB.AutoMigrate(app.Container.Models()...)