MCPcopy Index your code
hub / github.com/github/copilot-sdk / captureSetModelRequest

Function captureSetModelRequest

go/session_test.go:262–336  ·  view source on GitHub ↗
(t *testing.T, opts *SetModelOptions)

Source from the content-addressed store, hash-verified

260}
261
262func captureSetModelRequest(t *testing.T, opts *SetModelOptions) map[string]any {
263 t.Helper()
264
265 stdinR, stdinW := io.Pipe()
266 stdoutR, stdoutW := io.Pipe()
267 defer stdinR.Close()
268 defer stdinW.Close()
269 defer stdoutR.Close()
270 defer stdoutW.Close()
271
272 client := jsonrpc2.NewClient(stdinW, stdoutR)
273 client.Start()
274 defer client.Stop()
275
276 paramsCh := make(chan map[string]any, 1)
277 errCh := make(chan error, 1)
278
279 go func() {
280 frame, err := readTestJSONRPCFrame(stdinR)
281 if err != nil {
282 errCh <- err
283 return
284 }
285
286 var request struct {
287 ID json.RawMessage `json:"id"`
288 Method string `json:"method"`
289 Params map[string]any `json:"params"`
290 }
291 if err := json.Unmarshal(frame, &request); err != nil {
292 errCh <- err
293 return
294 }
295 if request.Method != "session.model.switchTo" {
296 errCh <- fmt.Errorf("expected session.model.switchTo, got %s", request.Method)
297 return
298 }
299
300 paramsCh <- request.Params
301
302 response := map[string]any{
303 "jsonrpc": "2.0",
304 "id": json.RawMessage(request.ID),
305 "result": map[string]any{},
306 }
307 data, err := json.Marshal(response)
308 if err != nil {
309 errCh <- err
310 return
311 }
312 if _, err := fmt.Fprintf(stdoutW, "Content-Length: %d\r\n\r\n%s", len(data), data); err != nil {
313 errCh <- err
314 return
315 }
316 }()
317
318 session := &Session{
319 SessionID: "session-1",

Calls 7

StartMethod · 0.95
StopMethod · 0.95
SetModelMethod · 0.95
readTestJSONRPCFrameFunction · 0.85
NewClientMethod · 0.80
MarshalMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…