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

Function TestHandler_Handle_POST_JSON

modules/httpdumps/handler_test.go:70–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestHandler_Handle_POST_JSON(t *testing.T) {
71 h := &handler{}
72 body := `{"key":"value"}`
73 r := httptest.NewRequest("POST", "/api/endpoint", strings.NewReader(body))
74 r.Header.Set("Content-Type", "application/json")
75 r.Host = "localhost:8000"
76
77 inc, err := h.Handle(r)
78 if err != nil {
79 t.Fatal(err)
80 }
81
82 var payload map[string]any
83 json.Unmarshal(inc.Payload, &payload)
84
85 req, _ := payload["request"].(map[string]any)
86 post, _ := req["post"].(map[string]any)
87 if post["key"] != "value" {
88 t.Errorf("post.key = %v", post["key"])
89 }
90}
91
92func TestHandler_Handle_POST_PlainBody(t *testing.T) {
93 h := &handler{}

Callers

nothing calls this directly

Calls 1

HandleMethod · 0.95

Tested by

no test coverage detected