@@ -20,9 +20,10 @@ func Test_ok(t *testing.T) {
2020 withInstanceProblem .Instance = "http://instance.example/"
2121
2222 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
2627 }{
2728 {
2829 "minimal" ,
@@ -36,6 +37,7 @@ func Test_ok(t *testing.T) {
3637 },
3738 },
3839 },
40+ nil ,
3941 },
4042 {
4143 "with detail" ,
@@ -50,6 +52,7 @@ func Test_ok(t *testing.T) {
5052 },
5153 },
5254 },
55+ nil ,
5356 },
5457 {
5558 "with instance" ,
@@ -64,6 +67,29 @@ func Test_ok(t *testing.T) {
6467 },
6568 },
6669 },
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+ },
6793 },
6894 }
6995 for _ , tc := range testCases {
@@ -74,7 +100,7 @@ func Test_ok(t *testing.T) {
74100 }
75101 problems .StatusProblemHandler (tc .problem ).ServeHTTP (rw , r )
76102 })
77- srv := httptest .NewServer (withSentryHub ()(New (Options {WaitForDelivery : true })(h )))
103+ srv := httptest .NewServer (withSentryHub ()(New (Options {WaitForDelivery : true , ConsiderProblematicStatusCode : tc . considerProblem })(h )))
78104 defer srv .Close ()
79105
80106 var mux sync.Mutex
0 commit comments