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

Function TestHandler_Handle_Envelope

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

Source from the content-addressed store, hash-verified

72}
73
74func TestHandler_Handle_Envelope(t *testing.T) {
75 h := &handler{}
76 payload := `{"message":"from envelope"}`
77 envelope := "{\"event_id\":\"env-uuid\"}\n" +
78 "{\"type\":\"event\",\"length\":" + strconv.Itoa(len(payload)) + "}\n" +
79 payload
80
81 r := httptest.NewRequest("POST", "/api/proj/store", strings.NewReader(envelope))
82 inc, err := h.Handle(r)
83 if err != nil {
84 t.Fatal(err)
85 }
86 if inc.UUID != "env-uuid" {
87 t.Errorf("UUID = %q, want %q", inc.UUID, "env-uuid")
88 }
89
90 var p map[string]any
91 json.Unmarshal(inc.Payload, &p)
92 if p["message"] != "from envelope" {
93 t.Errorf("payload message = %v", p["message"])
94 }
95}
96
97func TestHandler_Handle_EnvelopeMultilinePayload(t *testing.T) {
98 // Payload contains literal newlines — must rely on length, not newline split.

Callers

nothing calls this directly

Calls 1

HandleMethod · 0.95

Tested by

no test coverage detected