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

Function TestClient_ForwardsCapiOptionsToSessionRequests

go/client_test.go:214–251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestClient_ForwardsCapiOptionsToSessionRequests(t *testing.T) {
215 rpcClient, server, _ := newRuntimeShutdownRpcPair(t)
216 t.Cleanup(server.Stop)
217 client := &Client{
218 client: rpcClient,
219 RPC: rpc.NewServerRPC(rpcClient),
220 sessions: make(map[string]*Session),
221 }
222
223 createParams := make(chan json.RawMessage, 1)
224 server.SetRequestHandler("session.create", func(params json.RawMessage) (json.RawMessage, *jsonrpc2.Error) {
225 createParams <- append(json.RawMessage(nil), params...)
226 sessionID := sessionIDFromParams(t, params)
227 return []byte(`{"sessionId":"` + sessionID + `","workspacePath":"/workspace"}`), nil
228 })
229
230 _, err := client.CreateSession(t.Context(), &SessionConfig{
231 Capi: &CapiSessionOptions{EnableWebSocketResponses: Bool(false)},
232 })
233 if err != nil {
234 t.Fatalf("CreateSession failed: %v", err)
235 }
236 assertCapiEnableWebSocketResponses(t, <-createParams)
237
238 resumeParams := make(chan json.RawMessage, 1)
239 server.SetRequestHandler("session.resume", func(params json.RawMessage) (json.RawMessage, *jsonrpc2.Error) {
240 resumeParams <- append(json.RawMessage(nil), params...)
241 return []byte(`{"sessionId":"resumed-capi","workspacePath":"/workspace"}`), nil
242 })
243
244 _, err = client.ResumeSessionWithOptions(t.Context(), "resumed-capi", &ResumeSessionConfig{
245 Capi: &CapiSessionOptions{EnableWebSocketResponses: Bool(false)},
246 })
247 if err != nil {
248 t.Fatalf("ResumeSessionWithOptions failed: %v", err)
249 }
250 assertCapiEnableWebSocketResponses(t, <-resumeParams)
251}
252
253func TestClient_ForwardsNewSessionOptionsToSessionRequests(t *testing.T) {
254 rpcClient, server, _ := newRuntimeShutdownRpcPair(t)

Callers

nothing calls this directly

Calls 7

CreateSessionMethod · 0.95
sessionIDFromParamsFunction · 0.85
BoolFunction · 0.85
SetRequestHandlerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…