Skip to content

Commit

Permalink
Fix race in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Heckel committed Mar 30, 2022
1 parent d154d39 commit 59ec2de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,12 @@ func (t *testMailer) Send(from, to string, m *message) error {
return nil
}

func (t *testMailer) Count() int {
t.mu.Lock()
defer t.mu.Unlock()
return t.count
}

func TestServer_PublishTooRequests_Defaults(t *testing.T) {
s := newTestServer(t, newTestConfig(t))
for i := 0; i < 60; i++ {
Expand Down Expand Up @@ -902,7 +908,7 @@ func TestServer_PublishAsJSON_WithEmail(t *testing.T) {
m := toMessage(t, response.Body.String())
require.Equal(t, "mytopic", m.Topic)
require.Equal(t, "A message", m.Message)
require.Equal(t, 1, mailer.count)
require.Equal(t, 1, mailer.Count())
}

func TestServer_PublishAsJSON_Invalid(t *testing.T) {
Expand Down

0 comments on commit 59ec2de

Please sign in to comment.