-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransport_test.go
52 lines (41 loc) · 1.24 KB
/
transport_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
49
50
51
52
package sentry
import (
"testing"
"github.com/stretchr/testify/assert"
)
func ExampleUseTransport() {
var myTransport Transport
cl := NewClient(
// You can configure the transport to be used on a client level
UseTransport(myTransport),
)
cl.Capture(
// Or for a specific event when it is sent
UseTransport(myTransport),
)
}
func TestTransport(t *testing.T) {
assert.Nil(t, UseTransport(nil), "it should return nil if no transport is provided")
tr := newHTTPTransport()
o := UseTransport(tr)
assert.NotNil(t, o, "should not return a nil option")
assert.Implements(t, (*Option)(nil), o, "it should implement the Option interface")
assert.Equal(t, "sentry-go.transport", o.Class(), "it should use the right option class")
if assert.Implements(t, (*Option)(nil), o, "it should implement the OmitableOption interface") {
oo := o.(OmitableOption)
assert.True(t, oo.Omit(), "it should always return true for calls to Omit()")
}
}
func testNewTestTransport() *testTransport {
return &testTransport{
ch: make(chan Packet),
}
}
type testTransport struct {
ch chan Packet
err error
}
func (t *testTransport) Send(dsn string, packet Packet) error {
t.ch <- packet
return t.err
}