Fix race in test

pull/194/head v1.19.0
Philipp Heckel 2022-03-30 14:37:42 -04:00
parent d154d3936d
commit 59ec2de8bd
1 changed files with 7 additions and 1 deletions

View File

@ -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++ {
@ -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) {