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

Function TestStoreErrorEvent_SameFingerprint

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

Source from the content-addressed store, hash-verified

126}
127
128func TestStoreErrorEvent_SameFingerprint(t *testing.T) {
129 db := setupTestDB(t)
130
131 payload := json.RawMessage(`{
132 "event_id": "evt-1",
133 "level": "error",
134 "exception": {"values": [{"type": "RuntimeException", "value": "Same error"}]}
135 }`)
136
137 var ev ErrorEvent
138 json.Unmarshal(payload, &ev)
139 storeErrorEvent(db, &ev, payload, "")
140
141 // Send same exception type+value with different event_id.
142 payload2 := json.RawMessage(`{
143 "event_id": "evt-2",
144 "level": "error",
145 "exception": {"values": [{"type": "RuntimeException", "value": "Same error"}]}
146 }`)
147 json.Unmarshal(payload2, &ev)
148 ev.EventID = "evt-2"
149 storeErrorEvent(db, &ev, payload2, "")
150
151 payload3 := json.RawMessage(`{
152 "event_id": "evt-3",
153 "level": "error",
154 "exception": {"values": [{"type": "RuntimeException", "value": "Same error"}]}
155 }`)
156 json.Unmarshal(payload3, &ev)
157 ev.EventID = "evt-3"
158 storeErrorEvent(db, &ev, payload3, "")
159
160 // All 3 should have the same fingerprint.
161 rows, _ := db.Query(`SELECT fingerprint FROM sentry_error_events ORDER BY event_id`)
162 defer rows.Close()
163
164 var fingerprints []string
165 for rows.Next() {
166 var fp string
167 rows.Scan(&fp)
168 fingerprints = append(fingerprints, fp)
169 }
170
171 if len(fingerprints) != 3 {
172 t.Fatalf("expected 3 rows, got %d", len(fingerprints))
173 }
174 if fingerprints[0] != fingerprints[1] || fingerprints[1] != fingerprints[2] {
175 t.Errorf("fingerprints should all match: %v", fingerprints)
176 }
177}
178
179func TestStoreTransaction(t *testing.T) {
180 db := setupTestDB(t)

Callers

nothing calls this directly

Calls 3

storeErrorEventFunction · 0.85
ScanMethod · 0.80
setupTestDBFunction · 0.70

Tested by

no test coverage detected