(t *testing.T, agentFile string, runConfig *config.RuntimeConfig)
| 167 | } |
| 168 | |
| 169 | func startA2AServer(t *testing.T, agentFile string, runConfig *config.RuntimeConfig) a2a.AgentCard { |
| 170 | t.Helper() |
| 171 | |
| 172 | var lc net.ListenConfig |
| 173 | ln, err := lc.Listen(t.Context(), "tcp", ":0") |
| 174 | require.NoError(t, err) |
| 175 | |
| 176 | go func() { |
| 177 | _ = a2aserver.Run(t.Context(), agentFile, "root", filepath.Join(t.TempDir(), "session.db"), runConfig, ln) |
| 178 | }() |
| 179 | |
| 180 | port := ln.Addr().(*net.TCPAddr).Port |
| 181 | serverURL := fmt.Sprintf("http://localhost:%d", port) |
| 182 | |
| 183 | cardReq, err := http.NewRequestWithContext(t.Context(), http.MethodGet, serverURL+a2asrv.WellKnownAgentCardPath, http.NoBody) |
| 184 | require.NoError(t, err) |
| 185 | |
| 186 | resp, err := http.DefaultClient.Do(cardReq) |
| 187 | require.NoError(t, err) |
| 188 | defer resp.Body.Close() |
| 189 | |
| 190 | require.Equal(t, http.StatusOK, resp.StatusCode) |
| 191 | |
| 192 | var agentCard a2a.AgentCard |
| 193 | err = json.NewDecoder(resp.Body).Decode(&agentCard) |
| 194 | require.NoError(t, err) |
| 195 | |
| 196 | return agentCard |
| 197 | } |
no test coverage detected