Skip to content

Commit

Permalink
Merge pull request TheThingsNetwork#6631 from TheThingsNetwork/fix/te…
Browse files Browse the repository at this point in the history
…mplates-tests

Fix email templates tests
  • Loading branch information
adriansmares authored Oct 11, 2023
2 parents b0c7386 + 707b81f commit 2e8695e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/email/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var testTemplateData = email.NewTemplateData(
)

func TestEmailTemplates(t *testing.T) {
t.Parallel()
defer func() {
if t.Failed() {
t.Log("NOTE: If you encounter a diff, you may have to run this test with the -write-golden flag.")
Expand All @@ -60,7 +61,7 @@ func TestEmailTemplates(t *testing.T) {
UserId: "foo-usr",
}

for _, tt := range []struct {
for _, tc := range []struct {
TemplateName string
TemplateData email.TemplateData
}{
Expand Down Expand Up @@ -103,11 +104,13 @@ func TestEmailTemplates(t *testing.T) {
},
},
} {
t.Run(tt.TemplateName, func(t *testing.T) {
tc := tc
t.Run(tc.TemplateName, func(t *testing.T) {
t.Parallel()
a, ctx := test.New(t)

emailTemplate := email.GetTemplate(ctx, tt.TemplateName)
message, err := emailTemplate.Execute(tt.TemplateData)
emailTemplate := email.GetTemplate(ctx, tc.TemplateName)
message, err := emailTemplate.Execute(tc.TemplateData)
if a.So(err, should.BeNil) && a.So(message, should.NotBeNil) {
if err = compareMessageToGolden(message); err != nil {
t.Error(err)
Expand All @@ -118,6 +121,7 @@ func TestEmailTemplates(t *testing.T) {
}

func TestNotificationEmailTemplates(t *testing.T) {
t.Parallel()
defer func() {
if t.Failed() {
t.Log("NOTE: If you encounter a diff, you may have to run this test with the -write-golden flag.")
Expand Down Expand Up @@ -343,9 +347,11 @@ func TestNotificationEmailTemplates(t *testing.T) {
}),
},
} {
notification := ttnpb.Clone(notification)
notification.CreatedAt = now
notification.Email = true
t.Run(notification.NotificationType, func(t *testing.T) {
t.Parallel()
a, ctx := test.New(t)

emailNotification := email.GetNotification(ctx, notification.GetNotificationType())
Expand Down

0 comments on commit 2e8695e

Please sign in to comment.