From 19b9c7c9b8f7d1d44ef10de3c8c4a19d34b4580a Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Tue, 20 Oct 2026 19:02:26 -0400 Subject: [PATCH] =?UTF-8?q?fix(tests):=20wire=20settings=20registry=20into?= =?UTF-8?q?=20the=20test=20auth=20handler=20=E2=80=94=20unstick=20TestAdmi?= =?UTF-8?q?nCreateUser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setupTestServer built the settings registry (and wired it into systemSettingsHandler) but never called authHandler.SetSettings, unlike main.go:112. The auth handler therefore ran with a nil registry and defaultTimezone() took its nil-fallback branch, returning "UTC" for every Register/AdminCreateUser in tests regardless of the system default_timezone setting — so the 740213f0 inheritance pin in TestAdminCreateUser could never pass and failed every full-suite run. Also replace the TestAdminCreateUser "stable-ish" uniquifier (MaxConns is pinned to 1 by the harness, so it produced the same user every run and depended on the next run's cleanup sweep) with a real uuid suffix. --- cmd/server/tests/ownership_and_admin_test.go | 6 ++++-- cmd/server/tests/test_helpers_test.go | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/server/tests/ownership_and_admin_test.go b/cmd/server/tests/ownership_and_admin_test.go index accdda06..427f3759 100644 --- a/cmd/server/tests/ownership_and_admin_test.go +++ b/cmd/server/tests/ownership_and_admin_test.go @@ -183,8 +183,10 @@ func (s *OwnershipAndAdminTestSuite) TestHighlightDelete_CrossUserNoOp() { // create accounts even with self-service registration disabled, regular // users cannot, and duplicates conflict. func (s *OwnershipAndAdminTestSuite) TestAdminCreateUser() { - suffix := fmt.Sprintf("%d", s.setup.DBPool.Config().MaxConns) // stable-ish uniquifier - unique := fmt.Sprintf("admincreated%s", suffix) + // Real unique suffix: MaxConns is forced to 1 by the harness, so the old + // "stable-ish" uniquifier produced the same user every run and only + // survived on the setup-time cleanup sweep of the NEXT run. + unique := fmt.Sprintf("admincreated-%s", uuid.New().String()[:8]) // Regular user token → 403 (AdminMiddleware). payload, _ := json.Marshal(map[string]interface{}{ diff --git a/cmd/server/tests/test_helpers_test.go b/cmd/server/tests/test_helpers_test.go index dd8e120c..ca84928a 100644 --- a/cmd/server/tests/test_helpers_test.go +++ b/cmd/server/tests/test_helpers_test.go @@ -503,6 +503,10 @@ func setupTestServer(t *testing.T) *TestServerSetup { conflictHandler := handlers.NewConflictHandler(queries, connManager, progressService) analyticsHandler := handlers.NewAnalyticsHandler(queries) queueHandler := handlers.NewQueueHandler(queries, queueProcessor) + // main.go:112 wires the registry into the auth handler too — without it + // defaultTimezone() short-circuits to UTC and every new user (Register + + // AdminCreateUser) ignores the system default_timezone setting in tests. + authHandler.SetSettings(settingsRegistry) systemSettingsHandler := handlers.NewSystemSettingsHandler(queries) systemSettingsHandler.SetSettings(settingsRegistry) processingIssuesHandler := handlers.NewProcessingIssuesHandler(queries)