Преглед изворни кода

A mutex in a test struct ...

Philipp Heckel пре 4 година
родитељ
комит
6b46eb46e2
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      server/server_test.go

+ 4 - 0
server/server_test.go

@@ -11,6 +11,7 @@ import (
 	"os"
 	"path/filepath"
 	"strings"
+	"sync"
 	"testing"
 	"time"
 )
@@ -510,9 +511,12 @@ func TestServer_Curl_Publish_Poll(t *testing.T) {
 
 type testMailer struct {
 	count int
+	mu sync.Mutex
 }
 
 func (t *testMailer) Send(to string, m *message) error {
+	t.mu.Lock()
+	defer t.mu.Unlock()
 	t.count++
 	return nil
 }