From d03c4c777af4fe0798b693bfff4a3fd36535f2b6 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Fri, 31 Jul 2020 16:25:26 +0300 Subject: [PATCH] app/notification_email_test: attempt to fix a flaky test (#15080) Co-authored-by: Mattermod --- app/notification_email_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/notification_email_test.go b/app/notification_email_test.go index 957379baea..208fd76a5c 100644 --- a/app/notification_email_test.go +++ b/app/notification_email_test.go @@ -4,7 +4,9 @@ package app import ( + "bytes" "fmt" + "html/template" "regexp" "strings" "testing" @@ -266,8 +268,14 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTimeNoTimezone(t *testing TimeZone: zone, } + tmp, err := template.New("foo").Parse(`{{.}}`) + require.NoError(t, err) + var text bytes.Buffer + err = tmp.Execute(&text, fmt.Sprintf("sender - %s:%s %s, %s %s", formattedTime.Hour, formattedTime.Minute, formattedTime.TimeZone, formattedTime.Month, formattedTime.Day)) + require.NoError(t, err) + body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - postTimeLine := fmt.Sprintf("sender - %s:%s %s, %s %s", formattedTime.Hour, formattedTime.Minute, formattedTime.TimeZone, formattedTime.Month, formattedTime.Day) + postTimeLine := text.String() require.Contains(t, body, postTimeLine, fmt.Sprintf("Expected email text '%s'. Got %s", postTimeLine, body)) }