From 47cc3a187416c16f177cb8b87620385c1908d124 Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 2 Oct 2026 15:46:35 +0000 Subject: [PATCH] Clear the environment in the cmd/webhooker tests that build a Config (closes #452) TestNewApp_StopTimeout and TestNewApp_SendsFxEventsToTheLogger both build the app graph, which runs config.New, so a variable exported in the developer's shell reached them: METRICS_USERNAME without METRICS_PASSWORD failed the second. Both now call config.ClearEnvForTest before setting their own variables, as the config tests and the gormlog first-boot test already do. Model: opus-5-5 --- cmd/webhooker/main_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/webhooker/main_test.go b/cmd/webhooker/main_test.go index 851c4d8..ad1d5cf 100644 --- a/cmd/webhooker/main_test.go +++ b/cmd/webhooker/main_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sneak.berlin/go/webhooker/internal/config" "sneak.berlin/go/webhooker/internal/datadir" "sneak.berlin/go/webhooker/internal/resetpw" "sneak.berlin/go/webhooker/internal/server" @@ -36,6 +37,7 @@ const dockerStopGrace = 10 * time.Second // fx.New applies options before it executes invokes, so the timeout // is set whether or not the graph itself can be constructed here. func TestNewApp_StopTimeout(t *testing.T) { + config.ClearEnvForTest(t) t.Setenv("DATA_DIR", t.TempDir()) got := newApp().StopTimeout() @@ -73,6 +75,7 @@ func freePort(t *testing.T) int { // anything is built, and the run of logger.New, which happens before // the configuration sets the level. func TestNewApp_SendsFxEventsToTheLogger(t *testing.T) { + config.ClearEnvForTest(t) t.Setenv("DATA_DIR", t.TempDir()) t.Setenv("PORT", strconv.Itoa(freePort(t))) t.Setenv("DEBUG", "true")