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

Function TestStoreLogs

modules/sentry/storage_test.go:290–321  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

288}
289
290func TestStoreLogs(t *testing.T) {
291 db := setupTestDB(t)
292
293 logs := []LogRecord{
294 {TraceID: "trace-1", SpanID: "span-1", Level: "info", SeverityNumber: 9, Body: "Request started"},
295 {TraceID: "trace-1", Level: "warning", SeverityNumber: 13, Body: "Slow query detected"},
296 {Level: "error", SeverityNumber: 17, Body: "Connection refused"},
297 {Level: "debug", Body: "Cache hit"},
298 {Level: "info", Body: "Request completed"},
299 }
300
301 err := storeLogs(db, logs)
302 if err != nil {
303 t.Fatal(err)
304 }
305
306 var count int
307 db.QueryRow(`SELECT COUNT(*) FROM sentry_logs`).Scan(&count)
308 if count != 5 {
309 t.Errorf("log count = %d, want 5", count)
310 }
311
312 // Verify trace-linked log.
313 var traceID, level string
314 db.QueryRow(`SELECT trace_id, level FROM sentry_logs WHERE body = ?`, "Request started").Scan(&traceID, &level)
315 if traceID != "trace-1" {
316 t.Errorf("trace_id = %q, want 'trace-1'", traceID)
317 }
318 if level != "info" {
319 t.Errorf("level = %q, want 'info'", level)
320 }
321}
322
323func TestFingerprint(t *testing.T) {
324 t.Run("exception event", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

storeLogsFunction · 0.85
ScanMethod · 0.80
setupTestDBFunction · 0.70

Tested by

no test coverage detected