(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func 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 | } |
nothing calls this directly
no test coverage detected