Fix race in test

This commit is contained in:
Philipp Heckel 2022-03-30 14:37:42 -04:00
parent d154d3936d
commit 59ec2de8bd

View file

@ -714,6 +714,12 @@ func (t *testMailer) Send(from, to string, m *message) error {
return nil return nil
} }
func (t *testMailer) Count() int {
t.mu.Lock()
defer t.mu.Unlock()
return t.count
}
func TestServer_PublishTooRequests_Defaults(t *testing.T) { func TestServer_PublishTooRequests_Defaults(t *testing.T) {
s := newTestServer(t, newTestConfig(t)) s := newTestServer(t, newTestConfig(t))
for i := 0; i < 60; i++ { for i := 0; i < 60; i++ {
@ -902,7 +908,7 @@ func TestServer_PublishAsJSON_WithEmail(t *testing.T) {
m := toMessage(t, response.Body.String()) m := toMessage(t, response.Body.String())
require.Equal(t, "mytopic", m.Topic) require.Equal(t, "mytopic", m.Topic)
require.Equal(t, "A message", m.Message) 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) { func TestServer_PublishAsJSON_Invalid(t *testing.T) {