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

Function TestAPITraceDetail

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

Source from the content-addressed store, hash-verified

292}
293
294func TestAPITraceDetail(t *testing.T) {
295 mux := http.NewServeMux()
296 seedTestData(t, mux)
297
298 req := httptest.NewRequest("GET", "/api/sentry/traces/trace-abc", nil)
299 w := httptest.NewRecorder()
300 mux.ServeHTTP(w, req)
301
302 if w.Code != 200 {
303 t.Fatalf("status = %d, want 200", w.Code)
304 }
305
306 var resp map[string]any
307 json.Unmarshal(w.Body.Bytes(), &resp)
308
309 if resp["trace_id"] != "trace-abc" {
310 t.Errorf("trace_id = %v", resp["trace_id"])
311 }
312
313 txn := resp["transaction"].(map[string]any)
314 if txn["transaction_name"] != "GET /api/users" {
315 t.Errorf("transaction_name = %v", txn["transaction_name"])
316 }
317
318 spans := resp["spans"].([]any)
319 if len(spans) != 2 {
320 t.Errorf("spans length = %d, want 2", len(spans))
321 }
322
323 // Verify related errors.
324 relatedErrors := resp["related_errors"].([]any)
325 if len(relatedErrors) != 2 {
326 t.Errorf("related_errors = %d, want 2", len(relatedErrors))
327 }
328
329 // Verify related log count.
330 logCount := int(resp["related_log_count"].(float64))
331 if logCount != 2 {
332 t.Errorf("related_log_count = %d, want 2", logCount)
333 }
334}
335
336func TestAPITraceDetailNotFound(t *testing.T) {
337 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 2

seedTestDataFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected