fixes
This commit is contained in:
parent
1ddf6fe0c8
commit
4aeeee425b
5 changed files with 51 additions and 6 deletions
|
|
@ -29,3 +29,30 @@ func TestHumanTTLRoundsNetworkSkew(t *testing.T) {
|
|||
t.Fatalf("humanTTL = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestEmailContentUsesConfiguredAppName asserts the login-code email is
|
||||
// branded with the operator's configured product name, not the package's
|
||||
// internal "telesrv" fallback — the subject/body previously always said
|
||||
// "Your telesrv login code" regardless of Config.AppName.
|
||||
func TestEmailContentUsesConfiguredAppName(t *testing.T) {
|
||||
subject, body := emailContent("OwpenGram", "12345", 5*time.Minute)
|
||||
if subject != "Your OwpenGram login code" {
|
||||
t.Fatalf("subject = %q, want %q", subject, "Your OwpenGram login code")
|
||||
}
|
||||
if !strings.Contains(body, "Your OwpenGram login code is 12345.") {
|
||||
t.Fatalf("body missing branded code line: %q", body)
|
||||
}
|
||||
if strings.Contains(subject, "telesrv") || strings.Contains(body, "telesrv") {
|
||||
t.Fatalf("email still mentions telesrv instead of the configured app name:\nsubject=%q\nbody=%q", subject, body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewDefaultsAppNameToTelesrvWhenUnset asserts the package's own
|
||||
// self-contained fallback (used only if a caller forgets to pass AppName)
|
||||
// still works, mirroring FromName/TLSMode/Timeout's existing defaulting.
|
||||
func TestNewDefaultsAppNameToTelesrvWhenUnset(t *testing.T) {
|
||||
sender := New(Config{Host: "smtp.example.test", Port: 25, From: "noreply@example.test"})
|
||||
if sender.cfg.AppName != "telesrv" {
|
||||
t.Fatalf("cfg.AppName = %q, want default %q", sender.cfg.AppName, "telesrv")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue