test(smtp): add unit tests for SMTP config, env override, and send #19

Closed
Gravity Bot wants to merge 0 commits from feature/239-smtp-tests into release/v0.3.1
Contributor

Summary

Unit tests for the SMTP setup implementation (OP#164).

  • Config loading: env var override with table-driven cases (host, port, security, auth, defaults)
  • DB fallback: verifies nil pool takes DB path (not env path)
  • Message building: validates MIME headers and body format
  • Auth selection: plain, login (falls back to plain), cram-md5, none
  • Mock SMTP server: real TCP server for send path testing
  • Failure modes: unreachable host (all 3 security modes), missing from address
  • Handler tests: env-configured blocks update (403), empty email validation, graceful send failure

All tests pass with -race flag.

Closes OP#239

Test Plan

  • go test -race ./internal/services/ ./internal/handlers/ passes
  • go vet ./... clean
## Summary Unit tests for the SMTP setup implementation (OP#164). - **Config loading**: env var override with table-driven cases (host, port, security, auth, defaults) - **DB fallback**: verifies nil pool takes DB path (not env path) - **Message building**: validates MIME headers and body format - **Auth selection**: plain, login (falls back to plain), cram-md5, none - **Mock SMTP server**: real TCP server for send path testing - **Failure modes**: unreachable host (all 3 security modes), missing from address - **Handler tests**: env-configured blocks update (403), empty email validation, graceful send failure All tests pass with `-race` flag. Closes OP#239 ## Test Plan - [x] `go test -race ./internal/services/ ./internal/handlers/` passes - [x] `go vet ./...` clean
feat(smtp): add email/SMTP configuration and sending
All checks were successful
CI / test (pull_request) Successful in 1m42s
CI / security (pull_request) Successful in 1m47s
CI / build (pull_request) Successful in 1m50s
CI / lint (pull_request) Successful in 2m33s
c53233f35d
Add admin SMTP settings page with server config (host, port, security,
auth), credentials, sender info, enable toggle, and test email feature.
Supports env var override (GASHY_SMTP_*) with read-only UI when
env-configured. Implements EmailService with TLS/STARTTLS/plain modes.

Refs OP#164

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
test(smtp): add unit tests for SMTP config, env override, and send
Some checks failed
CI / security (pull_request) Successful in 1m44s
CI / test (pull_request) Successful in 1m45s
CI / build (pull_request) Successful in 1m50s
CI / lint (pull_request) Failing after 2m2s
59b211ab25
Tests cover: env var override logic with table-driven cases, DB fallback
path verification, message building, auth selection, mock SMTP server
send, unreachable host graceful failure, handler env-block (403), and
empty email validation.

Closes OP#239

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gravity Bot closed this pull request 2026-02-17 21:20:19 +00:00
Some checks failed
CI / security (pull_request) Successful in 1m44s
CI / test (pull_request) Successful in 1m45s
CI / build (pull_request) Successful in 1m50s
CI / lint (pull_request) Failing after 2m2s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mike/gashy!19
No description provided.