MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / sendJSON

Function sendJSON

internal/httpapi/agents_write_test.go:10–26  ·  view source on GitHub ↗
(t *testing.T, method, url, bearer string, body any)

Source from the content-addressed store, hash-verified

8)
9
10func sendJSON(t *testing.T, method, url, bearer string, body any) (int, map[string]any) {
11 t.Helper()
12 b, _ := json.Marshal(body)
13 req, _ := http.NewRequest(method, url, bytes.NewReader(b))
14 req.Header.Set("Content-Type", "application/json")
15 if bearer != "" {
16 req.Header.Set("Authorization", "Bearer "+bearer)
17 }
18 resp, err := http.DefaultClient.Do(req)
19 if err != nil {
20 t.Fatal(err)
21 }
22 defer resp.Body.Close()
23 var out map[string]any
24 _ = json.NewDecoder(resp.Body).Decode(&out)
25 return resp.StatusCode, out
26}
27
28// TestUpdateAgentName exercises the post-reshape agent PATCH: the only mutable
29// field is the display name (screening config moved to /protection).

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected