Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be00f59

Browse files
committed
chore(coderd/notifications): fix golden file test
1 parent 55e3d02 commit be00f59

File tree

2 files changed

+10
-69
lines changed

2 files changed

+10
-69
lines changed

coderd/notifications/dispatch/testdata/rendered-templates/TemplateWorkspaceDeleted.golden.html

Lines changed: 0 additions & 66 deletions
This file was deleted.

coderd/notifications/notifications_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,11 @@ func TestNotificationTemplates_Golden(t *testing.T) {
11111111
var msg *mocksmtp.Message
11121112
require.Eventually(t, func() bool {
11131113
msg = backend.LastMessage()
1114-
return msg != nil
1114+
return msg != nil && len(msg.Contents) > 0
11151115
}, testutil.WaitShort, testutil.IntervalFast)
1116-
require.NotNil(t, msg, "want a message to be sent")
1116+
1117+
// require.NotNil(t, msg, "want a message to be sent")
1118+
// require.NotEmpty(t, msg.Contents, "want a non-empty message")
11171119

11181120
body := normalizeGoldenEmail([]byte(msg.Contents))
11191121

@@ -1225,7 +1227,12 @@ func normalizeGoldenEmail(content []byte) []byte {
12251227
dateRegex := regexp.MustCompile(`Date: .+`)
12261228
messageIDRegex := regexp.MustCompile(`Message-Id: .+`)
12271229
boundaryRegex := regexp.MustCompile(`boundary=([0-9a-zA-Z]+)`)
1228-
boundary := boundaryRegex.FindSubmatch(content)[1]
1230+
submatches := boundaryRegex.FindSubmatch(content)
1231+
if len(submatches) == 0 {
1232+
return content
1233+
}
1234+
1235+
boundary := submatches[1]
12291236

12301237
content = dateRegex.ReplaceAll(content, []byte("Date: "+constantDate))
12311238
content = messageIDRegex.ReplaceAll(content, []byte("Message-Id: "+constantMessageID))

0 commit comments

Comments
 (0)