package mail import ( "strings" "testing" ) func sampleAnnouncement() Announcement { return Announcement{ CategoryLabel: "New features", Subject: "New in Vantage: scheduled workflows", BodyMarkdown: "Workflows can now run **on a schedule**.\n\n\n\n- cron syntax\n- time zones", UnsubscribeURL: "https://api.example/email/unsubscribe?c=features&t=abc", PreferencesURL: "https://hq.example/email-preferences?t=abc", PostalAddress: "Hostxtra Ltd, 1 High Street, Leeds", } } func TestRenderAnnouncement(t *testing.T) { subject, html, text, err := RenderAnnouncement(sampleAnnouncement(), "https://hq.example") if err != nil { t.Fatal(err) } if subject != "New in Vantage: scheduled workflows" { t.Errorf("subject = %q", subject) } if !strings.Contains(html, "on a schedule") { t.Error("markdown not rendered to html") } if strings.Contains(html, "