forked from getsentry/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks_test.go
44 lines (38 loc) · 835 Bytes
/
mocks_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
package sentry
import (
"sync"
"time"
)
type ScopeMock struct {
breadcrumb *Breadcrumb
shouldDropEvent bool
}
func (scope *ScopeMock) AddBreadcrumb(breadcrumb *Breadcrumb, limit int) {
scope.breadcrumb = breadcrumb
}
func (scope *ScopeMock) ApplyToEvent(event *Event, hint *EventHint) *Event {
if scope.shouldDropEvent {
return nil
}
return event
}
type TransportMock struct {
mu sync.Mutex
events []*Event
lastEvent *Event
}
func (t *TransportMock) Configure(options ClientOptions) {}
func (t *TransportMock) SendEvent(event *Event) {
t.mu.Lock()
defer t.mu.Unlock()
t.events = append(t.events, event)
t.lastEvent = event
}
func (t *TransportMock) Flush(timeout time.Duration) bool {
return true
}
func (t *TransportMock) Events() []*Event {
t.mu.Lock()
defer t.mu.Unlock()
return t.events
}