MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestSendGrid

Function TestSendGrid

pkg/email/sendgrid/sendgrid_test.go:29–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestSendGrid(t *testing.T) {
30 a := assertions.New(t)
31
32 apiKey := os.Getenv("SENDGRID_API_KEY")
33
34 sg, err := New(
35 log.NewContext(test.Context(), test.GetLogger(t)),
36 email.Config{
37 SenderConfig: email.SenderConfig{
38 SenderName: "Unit Test",
39 SenderAddress: "unit@test.local",
40 },
41 },
42 Config{
43 APIKey: apiKey,
44 SandboxMode: true,
45 },
46 )
47 a.So(err, should.BeNil)
48
49 err = sg.Send(&email.Message{
50 TemplateName: ttnpb.GetNotificationTypeString(ttnpb.NotificationType_UNKNOWN),
51 RecipientName: "John Doe",
52 RecipientAddress: "john.doe@example.com",
53 Subject: "Testing SendGrid",
54 HTMLBody: "<h1>Testing SendGrid</h1><p>We are testing SendGrid</p>",
55 TextBody: "****************\nTesting SendGrid\n****************\n\nWe are testing SendGrid",
56 })
57
58 if apiKey == "" {
59 a.So(err, should.NotBeNil)
60 } else {
61 a.So(err, should.BeNil)
62 }
63}

Callers

nothing calls this directly

Calls 7

NewContextFunction · 0.92
ContextFunction · 0.92
GetLoggerFunction · 0.92
NewFunction · 0.70
NewMethod · 0.65
SendMethod · 0.65

Tested by

no test coverage detected