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

Function TestAPIExceptionDetailByEventID

modules/sentry/api_test.go:214–246  ·  view source on GitHub ↗

TestAPIExceptionDetailByEventID covers Fix B: the detail endpoint must resolve by event_id (the key the list and the frontend route use) and still return the populated exceptions/breadcrumbs keyed off the internal id.

(t *testing.T)

Source from the content-addressed store, hash-verified

212// by event_id (the key the list and the frontend route use) and still return the
213// populated exceptions/breadcrumbs keyed off the internal id.
214func TestAPIExceptionDetailByEventID(t *testing.T) {
215 mux := http.NewServeMux()
216 seedTestData(t, mux)
217
218 req := httptest.NewRequest("GET", "/api/sentry/exceptions", nil)
219 w := httptest.NewRecorder()
220 mux.ServeHTTP(w, req)
221
222 var listResp map[string]any
223 json.Unmarshal(w.Body.Bytes(), &listResp)
224 first := listResp["data"].([]any)[0].(map[string]any)
225 eventID := first["event_id"].(string)
226 internalID := first["id"].(string)
227
228 req = httptest.NewRequest("GET", "/api/sentry/exceptions/"+eventID, nil)
229 w = httptest.NewRecorder()
230 mux.ServeHTTP(w, req)
231
232 if w.Code != 200 {
233 t.Fatalf("status = %d, want 200 for event_id lookup", w.Code)
234 }
235
236 var detail map[string]any
237 json.Unmarshal(w.Body.Bytes(), &detail)
238
239 if detail["id"] != internalID {
240 t.Errorf("detail id = %v, want internal id %q", detail["id"], internalID)
241 }
242 excs, ok := detail["exceptions"].([]any)
243 if !ok || len(excs) == 0 {
244 t.Errorf("exceptions empty for event_id lookup, want populated (got %v)", detail["exceptions"])
245 }
246}
247
248func TestAPIExceptionDetailNotFound(t *testing.T) {
249 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 2

seedTestDataFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected