Keep test helpers out of the shipped binary (closes #506)
check / check (push) Successful in 10m29s
check / check (push) Successful in 10m29s
The four testing.go files in config, database, middleware and session are gone. ClearEnvForTest moves to internal/config/configtest; the webhook database manager helpers move to internal/database/databasetest and the middleware's NewForTest to internal/middleware/middlewaretest, both now built through the production constructors. Tests that wrapped an open main database use database.Open. The session helpers move into the session package's export_test.go; the middleware tests build their session through session.New and age its timestamps instead of using a fake clock. The session, middleware and webhook database manager now take the *slog.Logger they log through, so tests in other packages can give them their own. Model: opus-5-5
This commit is contained in:
@@ -3,6 +3,7 @@ package gormlog_test
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -13,6 +14,7 @@ import (
|
||||
"go.uber.org/fx/fxtest"
|
||||
_ "modernc.org/sqlite" // Pure Go SQLite driver.
|
||||
"sneak.berlin/go/webhooker/internal/config"
|
||||
"sneak.berlin/go/webhooker/internal/config/configtest"
|
||||
"sneak.berlin/go/webhooker/internal/database"
|
||||
"sneak.berlin/go/webhooker/internal/globals"
|
||||
"sneak.berlin/go/webhooker/internal/logger"
|
||||
@@ -128,7 +130,7 @@ func readFirstBootSecrets(
|
||||
func bootAtDebug(t *testing.T, dataDir string) string {
|
||||
t.Helper()
|
||||
|
||||
config.ClearEnvForTest(t)
|
||||
configtest.ClearEnvForTest(t)
|
||||
t.Setenv("DEBUG", "true")
|
||||
t.Setenv("DATA_DIR", dataDir)
|
||||
|
||||
@@ -145,6 +147,7 @@ func bootAtDebug(t *testing.T, dataDir string) string {
|
||||
fx.Provide(
|
||||
globals.New,
|
||||
logger.New,
|
||||
func(l *logger.Logger) *slog.Logger { return l.Get() },
|
||||
config.New,
|
||||
database.New,
|
||||
session.New,
|
||||
|
||||
Reference in New Issue
Block a user