Skip to content

fix(email): unbreak factory_test.go after #333 merge glitch#337

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/email-factory-test-merge-glitch
May 11, 2026
Merged

fix(email): unbreak factory_test.go after #333 merge glitch#337
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/email-factory-test-merge-glitch

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 11, 2026

Summary

Reproduction

git checkout origin/feat/multicloud-web-frontend
gofmt -l internal/email/factory_test.go
# internal/email/factory_test.go:309:2: missing ',' before newline in argument list
# internal/email/factory_test.go:312:6: expected '(', found TestNewSenderWithConfig_AWS
# ...

Or check the failing pre-commit step on any open PR against the base — same error shape.

Test plan

Summary by CodeRabbit

  • Tests
    • Improved environment variable cleanup and restoration in email factory tests for more robust test isolation.

Review Change Stack

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.
@cristim cristim added triaged Item has been triaged priority/p0 Drop everything; same-day fix severity/high Significant harm urgency/now Drop other things impact/all-users Affects every user effort/xs Trivial / one-liner type/bug Defect labels May 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c68476c6-4cba-4dba-a764-08c93e1b4e1d

📥 Commits

Reviewing files that changed from the base of the PR and between 80ef684 and 3273355.

📒 Files selected for processing (1)
  • internal/email/factory_test.go
💤 Files with no reviewable changes (1)
  • internal/email/factory_test.go

📝 Walkthrough

Walkthrough

The TestNewSenderFromEnvironment_EmailEnabled test's "unset_falls_through" sub-test was adjusted to capture the prior EMAIL_ENABLED environment value using os.LookupEnv and restore or unset it via t.Cleanup, improving test isolation.

Changes

Test Environment Isolation

Layer / File(s) Summary
Test Environment Capture and Restoration
internal/email/factory_test.go
Environment variable handling in the "unset_falls_through" sub-test now snapshots the prior EMAIL_ENABLED value via os.LookupEnv, unsets it for the test, and properly restores or unsets it in t.Cleanup to ensure isolation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • LeanerCloud/CUDly#333: Both PRs modify internal/email/factory_test.go and deal with EMAIL_ENABLED test behavior; PR #333 adds the test that PR #337 improves.

Poem

🐰 A test once leaked its env state wild,
Now cleanup captures what ran defiled,
With LookupEnv and Cleanup's care,
The EMAIL_ENABLED flows pure and fair! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning This PR addresses a merge conflict/syntax error in factory_test.go, while linked issue #332 requires functional changes to factory.go and new nop_sender.go. The PR does not implement the coding requirements from #332. This PR only fixes the test file syntax. Implement the functional requirements from #332: add EMAIL_ENABLED early-return logic, create NopSender implementation, add debug logging, update templates.go logging, and ensure no test regressions.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the fix: restoring factory_test.go after a merge conflict from PR #333 caused by overlapping sub-tests and duplicate code.
Out of Scope Changes check ✅ Passed The PR scope is appropriately limited to restoring the correct test structure in factory_test.go after a merge conflict, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • ✅ Committed to branch successfully - (🔄 Check to regenerate)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/email-factory-test-merge-glitch

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 11, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Caution

Docstrings generation - FAILED

No docstrings were generated.

@cristim cristim merged commit 186204b into feat/multicloud-web-frontend May 11, 2026
4 checks passed
@cristim cristim deleted the fix/email-factory-test-merge-glitch branch May 11, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/all-users Affects every user priority/p0 Drop everything; same-day fix severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/now Drop other things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant