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

Function TestHandleEnvelope

modules/sentry/handler_test.go:230–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestHandleEnvelope(t *testing.T) {
231 h := &handler{} // no db — structured storage silently skipped
232
233 t.Run("valid envelope", func(t *testing.T) {
234 body := []byte(`{"event_id":"test-id"}
235{"type":"event"}
236{"message":"payload data"}`)
237 inc, err := h.handleEnvelope(body, "proj")
238 if err != nil {
239 t.Fatal(err)
240 }
241 if inc.UUID != "test-id" {
242 t.Errorf("UUID = %q, want %q", inc.UUID, "test-id")
243 }
244 if inc.Project != "proj" {
245 t.Errorf("Project = %q, want %q", inc.Project, "proj")
246 }
247 })
248
249 t.Run("envelope without valid payload returns nil", func(t *testing.T) {
250 body := []byte(`{"event_id":"test-id"}
251{"type":"event"}
252not valid json`)
253 inc, err := h.handleEnvelope(body, "")
254 if err != nil {
255 t.Fatal(err)
256 }
257 // Envelopes with no valid JSON payload return nil — the handler matched
258 // but there's nothing to store in the canonical events table.
259 if inc != nil {
260 t.Errorf("expected nil incoming for invalid payload, got %+v", inc)
261 }
262 })
263}
264
265// TestHandler_NumericProject_Envelope routes a numeric DSN envelope to the
266// default project (empty project) — the JS SDK path of issue #338.

Callers

nothing calls this directly

Calls 2

handleEnvelopeMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected