(t *testing.T)
| 259 | } |
| 260 | |
| 261 | func TestAPITracesList(t *testing.T) { |
| 262 | mux := http.NewServeMux() |
| 263 | seedTestData(t, mux) |
| 264 | |
| 265 | req := httptest.NewRequest("GET", "/api/sentry/traces", nil) |
| 266 | w := httptest.NewRecorder() |
| 267 | mux.ServeHTTP(w, req) |
| 268 | |
| 269 | if w.Code != 200 { |
| 270 | t.Fatalf("status = %d, want 200", w.Code) |
| 271 | } |
| 272 | |
| 273 | var resp map[string]any |
| 274 | json.Unmarshal(w.Body.Bytes(), &resp) |
| 275 | |
| 276 | data := resp["data"].([]any) |
| 277 | if len(data) != 1 { |
| 278 | t.Fatalf("data length = %d, want 1", len(data)) |
| 279 | } |
| 280 | |
| 281 | trace := data[0].(map[string]any) |
| 282 | if trace["transaction_name"] != "GET /api/users" { |
| 283 | t.Errorf("transaction_name = %v", trace["transaction_name"]) |
| 284 | } |
| 285 | if trace["preview_spans"] == nil { |
| 286 | t.Error("expected preview_spans") |
| 287 | } |
| 288 | spans := trace["preview_spans"].([]any) |
| 289 | if len(spans) < 1 { |
| 290 | t.Error("expected at least 1 preview span") |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | func TestAPITraceDetail(t *testing.T) { |
| 295 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected