chore(tests): Attempting to fix flaxy SMTP unit test (#92786)

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
Dave Henderson
2024-09-04 16:25:44 -04:00
committed by GitHub
parent d8b6a5bde2
commit c00a3bed42
4 changed files with 10 additions and 8 deletions

View File

@@ -294,16 +294,16 @@ func TestSmtpSend(t *testing.T) {
count, err := client.Send(ctx, msgs...)
require.NoError(t, err)
require.Equal(t, 3, count)
assert.Equal(t, 3, count)
// workaround for https://github.com/mocktools/go-smtp-mock/issues/181
time.Sleep(1 * time.Millisecond)
messages := srv.MessagesAndPurge()
require.Len(t, messages, 3)
assert.Len(t, messages, 3)
for i, sentMsg := range messages {
rcpts := sentMsg.RcpttoRequestResponse()
require.EqualValues(t, [][]string{
assert.EqualValues(t, [][]string{
{fmt.Sprintf("RCPT TO:<rcpt%d@example.com>", i+1), "250 Received"},
}, rcpts)
@@ -316,7 +316,7 @@ func TestSmtpSend(t *testing.T) {
// make sure the trace is propagated
traceId := span.SpanContext().TraceID().String()
hasPrefix := strings.HasPrefix(hdr.Get("traceparent"), "00-"+traceId+"-")
require.True(t, hasPrefix)
assert.True(t, hasPrefix)
// one of the lines should be the body we expect!
found := false
@@ -334,7 +334,7 @@ func TestSmtpSend(t *testing.T) {
}
}
require.True(t, found)
assert.True(t, found)
}
})
}