MCPcopy Create free account
hub / github.com/buggregator/server / TestAPIExceptionsChronological

Function TestAPIExceptionsChronological

modules/sentry/api_test.go:70–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestAPIExceptionsChronological(t *testing.T) {
71 mux := http.NewServeMux()
72 seedTestData(t, mux)
73
74 req := httptest.NewRequest("GET", "/api/sentry/exceptions", nil)
75 w := httptest.NewRecorder()
76 mux.ServeHTTP(w, req)
77
78 if w.Code != 200 {
79 t.Fatalf("status = %d, want 200", w.Code)
80 }
81
82 var resp map[string]any
83 json.Unmarshal(w.Body.Bytes(), &resp)
84
85 data := resp["data"].([]any)
86 if len(data) != 3 {
87 t.Fatalf("data length = %d, want 3", len(data))
88 }
89
90 // First item should be most recent.
91 first := data[0].(map[string]any)
92 if first["level"] == nil {
93 t.Error("expected level field")
94 }
95
96 // Check occurrence_count for RuntimeException events.
97 for _, item := range data {
98 m := item.(map[string]any)
99 if m["exception_type"] == "RuntimeException" {
100 count := int(m["occurrence_count"].(float64))
101 if count != 2 {
102 t.Errorf("occurrence_count = %d, want 2 for RuntimeException", count)
103 }
104 }
105 }
106
107 meta := resp["meta"].(map[string]any)
108 if int(meta["total"].(float64)) != 3 {
109 t.Errorf("meta.total = %v, want 3", meta["total"])
110 }
111}
112
113func TestAPIExceptionsGrouped(t *testing.T) {
114 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 2

seedTestDataFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected