MCPcopy Index your code
hub / github.com/docker/docker-agent / sendA2AMessage

Function sendA2AMessage

e2e/a2a_test.go:133–167  ·  view source on GitHub ↗

sendA2AMessage sends a message/send JSON-RPC request and returns the parsed response.

(t *testing.T, url, requestID, messageID, text string)

Source from the content-addressed store, hash-verified

131
132// sendA2AMessage sends a message/send JSON-RPC request and returns the parsed response.
133func sendA2AMessage(t *testing.T, url, requestID, messageID, text string) a2aResponse {
134 t.Helper()
135
136 body, err := json.Marshal(map[string]any{
137 "jsonrpc": "2.0",
138 "id": requestID,
139 "method": "message/send",
140 "params": map[string]any{
141 "message": map[string]any{
142 "messageId": messageID,
143 "role": "user",
144 "parts": []map[string]any{{"kind": "text", "text": text}},
145 },
146 },
147 })
148 require.NoError(t, err)
149
150 req, err := http.NewRequestWithContext(t.Context(), http.MethodPost, url, bytes.NewReader(body))
151 require.NoError(t, err)
152 req.Header.Set("Content-Type", "application/json")
153
154 resp, err := http.DefaultClient.Do(req)
155 require.NoError(t, err)
156 defer resp.Body.Close()
157
158 require.Equal(t, http.StatusOK, resp.StatusCode)
159
160 data, err := io.ReadAll(resp.Body)
161 require.NoError(t, err)
162
163 var parsed a2aResponse
164 require.NoError(t, json.Unmarshal(data, &parsed))
165
166 return parsed
167}
168
169func startA2AServer(t *testing.T, agentFile string, runConfig *config.RuntimeConfig) a2a.AgentCard {
170 t.Helper()

Callers 3

TestA2AServer_InvokeFunction · 0.85
TestA2AServer_MultiAgentFunction · 0.85

Calls 4

ContextMethod · 0.80
DoMethod · 0.65
CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected