From 3273355f829e1f795cbb9c865315689c28bc0223 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Mon, 11 May 2026 22:49:58 +0200 Subject: [PATCH] fix(email): unbreak factory_test.go after #333 merge glitch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #333 (closes #332) landed a botched merge of `unset_falls_through` in TestNewSenderFromEnvironment_EmailEnabled — two overlapping copies of the same sub-test ended up concatenated (one missing its closing braces, one preceded by stray fragments), plus duplicate `ctx :=` / `sender, err :=` lines. The result didn't parse: gofmt -l internal/email/factory_test.go internal/email/factory_test.go:309:2: missing ',' before newline ... internal/email/factory_test.go:312:6: expected '(', found TestNewSenderWithConfig_AWS This trips `gofmt` and `go vet` in the pre-commit workflow on every open PR against `feat/multicloud-web-frontend` (e.g. #326, #335, #336). Keep the `prev/hadPrev` version of the sub-test (the one that actually does `os.Unsetenv` first, which is the case the test name describes), drop the orphaned `orig/hadOrig` fragment, and remove the duplicate ctx/sender declarations. Verified locally: gofmt clean, `go vet ./internal/email/...` clean, `go test ./internal/email/...` 306 tests pass. --- internal/email/factory_test.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/internal/email/factory_test.go b/internal/email/factory_test.go index 1c104d5b..569d115f 100644 --- a/internal/email/factory_test.go +++ b/internal/email/factory_test.go @@ -255,14 +255,6 @@ func TestNewSenderFromEnvironment_EmailEnabled(t *testing.T) { } // Unset / empty → factory takes the default-enabled path. - t.Run("unset_falls_through", func(t *testing.T) { - orig, hadOrig := os.LookupEnv("EMAIL_ENABLED") - t.Cleanup(func() { - if hadOrig { - os.Setenv("EMAIL_ENABLED", orig) - } else { - os.Unsetenv("EMAIL_ENABLED") - } t.Run("unset_falls_through", func(t *testing.T) { prev, hadPrev := os.LookupEnv("EMAIL_ENABLED") os.Unsetenv("EMAIL_ENABLED") @@ -276,8 +268,6 @@ func TestNewSenderFromEnvironment_EmailEnabled(t *testing.T) { aws(t) ctx := context.Background() sender, err := NewSenderFromEnvironment(ctx) - ctx := context.Background() - sender, err := NewSenderFromEnvironment(ctx) require.NoError(t, err) _, ok := sender.(*Sender) assert.True(t, ok, "Expected AWS Sender when EMAIL_ENABLED is unset")