Skip to content

Commit 0636e03

Browse files
committed
Fix test
1 parent 2783cce commit 0636e03

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

services/mailer/sender/main_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package sender
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/unittest"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
unittest.MainTest(m)
14+
}

services/mailer/sender/message_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,17 @@ func TestToMessage(t *testing.T) {
5454
Body: "Some Issue got closed by Y-Man",
5555
}
5656

57+
assertHeaders := func(t *testing.T, expected, header map[string]string) {
58+
for k, v := range expected {
59+
assert.Equal(t, v, header[k])
60+
}
61+
}
62+
5763
buf := &strings.Builder{}
5864
_, err := m1.ToMessage().WriteTo(buf)
5965
assert.NoError(t, err)
6066
header, _ := extractMailHeaderAndContent(t, buf.String())
61-
assert.EqualValues(t, map[string]string{
67+
assertHeaders(t, map[string]string{
6268
"Content-Type": "multipart/alternative;",
6369
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
6470
"From": "\"Test Gitea\" <[email protected]>",
@@ -78,7 +84,7 @@ func TestToMessage(t *testing.T) {
7884
_, err = m1.ToMessage().WriteTo(buf)
7985
assert.NoError(t, err)
8086
header, _ = extractMailHeaderAndContent(t, buf.String())
81-
assert.EqualValues(t, map[string]string{
87+
assertHeaders(t, map[string]string{
8288
"Content-Type": "multipart/alternative;",
8389
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
8490
"From": "\"Test Gitea\" <[email protected]>",

0 commit comments

Comments
 (0)