All checks were successful
check / check (push) Successful in 4s
Add comprehensive test coverage for three previously-untested packages: delivery (37% → 75%): - processNewTask with inline and large (DB-fetched) bodies - processRetryTask success, skip non-retrying, large body fetch - Worker lifecycle start/stop, retry channel processing - processDelivery unknown target type handling - recoverPendingDeliveries, recoverWebhookDeliveries, recoverInFlight - HTTP delivery with custom headers, timeout, invalid config - Notify batching middleware (0% → 70%): - Logging middleware status code capture and pass-through - LoggingResponseWriter delegation - CORS dev mode (allow-all) and prod mode (no-op) - RequireAuth redirect for unauthenticated, pass-through for authenticated - MetricsAuth basic auth validation - ipFromHostPort helper session (0% → 52%): - Get/Save round-trip with real cookie store - SetUser, GetUserID, GetUsername, IsAuthenticated - ClearUser removes all keys - Destroy invalidates session (MaxAge -1) - Session persistence across requests - Edge cases: overwrite user, wrong type, constants Test helpers added: - database.NewTestDatabase / NewTestWebhookDBManager for cross-package testing - session.NewForTest for middleware tests without fx lifecycle closes #28
20 lines
502 B
Go
20 lines
502 B
Go
package session
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/gorilla/sessions"
|
|
"sneak.berlin/go/webhooker/internal/config"
|
|
)
|
|
|
|
// NewForTest creates a Session with a pre-configured cookie store for use
|
|
// in tests. This bypasses the fx lifecycle and database dependency, allowing
|
|
// middleware and handler tests to use real session functionality.
|
|
func NewForTest(store *sessions.CookieStore, cfg *config.Config, log *slog.Logger) *Session {
|
|
return &Session{
|
|
store: store,
|
|
config: cfg,
|
|
log: log,
|
|
}
|
|
}
|