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

Function TestStoreErrorEvent

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

Source from the content-addressed store, hash-verified

29}
30
31func TestStoreErrorEvent(t *testing.T) {
32 db := setupTestDB(t)
33
34 payload := json.RawMessage(`{
35 "event_id": "abc123",
36 "level": "error",
37 "platform": "php",
38 "environment": "production",
39 "server_name": "web-1",
40 "transaction": "GET /users",
41 "exception": {
42 "values": [
43 {
44 "type": "RuntimeException",
45 "value": "Something went wrong",
46 "mechanism": {"type": "generic", "handled": false},
47 "stacktrace": {"frames": [{"filename": "app.php", "lineno": 42}]}
48 },
49 {
50 "type": "LogicException",
51 "value": "Root cause",
52 "mechanism": {"type": "chained", "handled": true}
53 }
54 ]
55 },
56 "breadcrumbs": {
57 "values": [
58 {"type": "http", "category": "request", "level": "info", "message": "GET /api"},
59 {"type": "query", "category": "db", "level": "debug", "message": "SELECT *"}
60 ]
61 },
62 "contexts": {
63 "trace": {"trace_id": "aabbccdd", "span_id": "1234"}
64 }
65 }`)
66
67 var ev ErrorEvent
68 if err := json.Unmarshal(payload, &ev); err != nil {
69 t.Fatal(err)
70 }
71
72 id, err := storeErrorEvent(db, &ev, payload, "myproject")
73 if err != nil {
74 t.Fatal(err)
75 }
76 if id == "" {
77 t.Fatal("expected non-empty ID")
78 }
79
80 // Verify sentry_error_events row.
81 var level, fingerprint, traceID string
82 var handled int
83 err = db.QueryRow(
84 `SELECT level, fingerprint, trace_id, handled FROM sentry_error_events WHERE event_id = ?`, "abc123",
85 ).Scan(&level, &fingerprint, &traceID, &handled)
86 if err != nil {
87 t.Fatal(err)
88 }

Callers

nothing calls this directly

Calls 3

storeErrorEventFunction · 0.85
ScanMethod · 0.80
setupTestDBFunction · 0.70

Tested by

no test coverage detected