(t *testing.T)
| 212 | } |
| 213 | |
| 214 | func 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 | |
| 253 | func TestClient_ForwardsNewSessionOptionsToSessionRequests(t *testing.T) { |
| 254 | rpcClient, server, _ := newRuntimeShutdownRpcPair(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…