-
Notifications
You must be signed in to change notification settings - Fork 40
/
race_test.go
48 lines (40 loc) · 934 Bytes
/
race_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gobrake_test
import (
"net/http"
"net/http/httptest"
"sync"
. "github.com/onsi/ginkgo/v2"
"github.com/airbrake/gobrake/v5"
)
var _ = Describe("Notifier", func() {
var notifier *gobrake.Notifier
BeforeEach(func() {
handler := func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusCreated)
_, err := w.Write([]byte(`{"id":"123"}`))
if err != nil {
panic(err)
}
}
server := httptest.NewServer(http.HandlerFunc(handler))
configServer := newConfigServer()
notifier = gobrake.NewNotifierWithOptions(&gobrake.NotifierOptions{
ProjectId: 1,
ProjectKey: "key",
Host: server.URL,
RemoteConfigHost: configServer.URL,
})
})
It("is race free", func() {
var wg sync.WaitGroup
for i := 0; i < 100; i++ {
wg.Add(1)
go func() {
defer wg.Done()
notifier.Notify("hello", nil)
}()
}
wg.Wait()
notifier.Flush()
})
})