feat(04-03): register plugin mail layouts and publish the mailer at boot
- Map short layout names onto dotted layout files and wrap text/HTML - party.Activate publishes postcard.Mailer before Boot and names missing files - Hello plugin sends through the app-scoped mailer Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"git.golem15.com/golem15/summercms/pact"
|
||||
"git.golem15.com/golem15/summercms/party"
|
||||
"git.golem15.com/golem15/summercms/phrasebook"
|
||||
"git.golem15.com/golem15/summercms/postcard"
|
||||
"git.golem15.com/golem15/summercms/surf"
|
||||
)
|
||||
|
||||
@@ -142,6 +143,35 @@ func TestHelloPluginResolvesLang(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelloPluginSendsMail(t *testing.T) {
|
||||
cfg, err := compass.Load("config")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
app := backpack.New(cfg)
|
||||
if _, err := party.Activate(app, []string{"golem15.hello"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mail, ok := app.Lookup[postcard.Mailer]()
|
||||
if !ok {
|
||||
t.Fatal("mailer not published")
|
||||
}
|
||||
if err := mail.Send(t.Context(), postcard.Message{
|
||||
Template: "golem15.hello::mail.hello",
|
||||
To: []string{"ada@example.test"},
|
||||
Vars: map[string]any{"Name": "Ada", "URL": "https://example.test"},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := mail.Send(t.Context(), postcard.Message{
|
||||
Template: "golem15.hello::mail.hello-en",
|
||||
To: []string{"ada@example.test"},
|
||||
Vars: map[string]any{"Name": "Ada", "URL": "https://example.test"},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTypedItemRoute(t *testing.T) {
|
||||
cfg, err := compass.Load("config")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user