-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler_integration_test.go
69 lines (49 loc) · 1.26 KB
/
handler_integration_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package sentry
import (
"net/http"
"os"
"testing"
"time"
"github.com/pkg/errors"
"emperror.dev/emperror"
"emperror.dev/emperror/httperr"
)
func newHandler(t *testing.T) *Handler {
dsn := os.Getenv("SENTRY_DSN")
if dsn == "" {
t.Skip("missing sentry credentials")
}
handler, err := New(dsn)
if err != nil {
t.Fatal(err)
}
return handler
}
func TestIntegration_Handler(t *testing.T) {
handler := newHandler(t)
defer handler.Close()
err := errors.New("error")
handler.Handle(err)
// Wait for the notice to reach the queue before closing
time.Sleep(500 * time.Millisecond)
}
func TestIntegration_WithContext(t *testing.T) {
handler := newHandler(t)
defer handler.Close()
err := emperror.With(errors.New("error with context"), "key", "value")
handler.Handle(err)
// Wait for the notice to reach the queue before closing
time.Sleep(500 * time.Millisecond)
}
func TestIntegration_WithHTTPRequest(t *testing.T) {
handler := newHandler(t)
defer handler.Close()
req, e := http.NewRequest("GET", "https://google.com", nil)
if e != nil {
t.Fatal(e)
}
err := httperr.WithHTTPRequest(errors.New("error with http request"), req)
handler.Handle(err)
// Wait for the notice to reach the queue before closing
time.Sleep(500 * time.Millisecond)
}