@@ -20,9 +20,10 @@ func Test_ok(t *testing.T) {
20
20
withInstanceProblem .Instance = "http://instance.example/"
21
21
22
22
testCases := []struct {
23
- name string
24
- problem * problems.DefaultProblem
25
- wantEvents []* sentrysdk.Event
23
+ name string
24
+ problem * problems.DefaultProblem
25
+ wantEvents []* sentrysdk.Event
26
+ considerProblem func (statusCode int ) bool
26
27
}{
27
28
{
28
29
"minimal" ,
@@ -36,6 +37,7 @@ func Test_ok(t *testing.T) {
36
37
},
37
38
},
38
39
},
40
+ nil ,
39
41
},
40
42
{
41
43
"with detail" ,
@@ -50,6 +52,7 @@ func Test_ok(t *testing.T) {
50
52
},
51
53
},
52
54
},
55
+ nil ,
53
56
},
54
57
{
55
58
"with instance" ,
@@ -64,6 +67,29 @@ func Test_ok(t *testing.T) {
64
67
},
65
68
},
66
69
},
70
+ nil ,
71
+ },
72
+ {
73
+ "client error" ,
74
+ problems .NewStatusProblem (http .StatusBadRequest ),
75
+ nil ,
76
+ nil ,
77
+ },
78
+ {
79
+ "capture client error" ,
80
+ problems .NewStatusProblem (http .StatusBadRequest ),
81
+ []* sentrysdk.Event {
82
+ {
83
+ Level : sentrysdk .LevelInfo ,
84
+ Message : http .StatusText (http .StatusBadRequest ),
85
+ Extra : map [string ]interface {}{
86
+ "problem.status" : http .StatusBadRequest ,
87
+ },
88
+ },
89
+ },
90
+ func (statusCode int ) bool {
91
+ return statusCode >= 400 && statusCode < 500
92
+ },
67
93
},
68
94
}
69
95
for _ , tc := range testCases {
@@ -74,7 +100,7 @@ func Test_ok(t *testing.T) {
74
100
}
75
101
problems .StatusProblemHandler (tc .problem ).ServeHTTP (rw , r )
76
102
})
77
- srv := httptest .NewServer (withSentryHub ()(New (Options {WaitForDelivery : true })(h )))
103
+ srv := httptest .NewServer (withSentryHub ()(New (Options {WaitForDelivery : true , ConsiderProblematicStatusCode : tc . considerProblem })(h )))
78
104
defer srv .Close ()
79
105
80
106
var mux sync.Mutex
0 commit comments