MCPcopy
hub / github.com/coder/mux / startWorkspaceTurnForTest

Function startWorkspaceTurnForTest

src/node/services/taskService.test.ts:559–641  ·  view source on GitHub ↗
(
    options: {
      stableIds?: string[];
      disposable?: boolean;
      sendMessage?: ReturnType<typeof mock>;
      remove?: ReturnType<typeof mock>;
      isStreaming?: ReturnType<typeof mock>;
      hasQueuedMessages?: ReturnType<typeof mock>;
      hasPendingQueuedOrPreparingTurn?: ReturnType<typeof mock>;
      waitForPendingStreamErrorRecoveryDecision?: ReturnType<typeof mock>;
    } = {}
  )

Source from the content-addressed store, hash-verified

557 });
558
559 async function startWorkspaceTurnForTest(
560 options: {
561 stableIds?: string[];
562 disposable?: boolean;
563 sendMessage?: ReturnType<typeof mock>;
564 remove?: ReturnType<typeof mock>;
565 isStreaming?: ReturnType<typeof mock>;
566 hasQueuedMessages?: ReturnType<typeof mock>;
567 hasPendingQueuedOrPreparingTurn?: ReturnType<typeof mock>;
568 waitForPendingStreamErrorRecoveryDecision?: ReturnType<typeof mock>;
569 } = {}
570 ) {
571 const config = await createTestConfig(rootDir);
572 stubStableIds(config, options.stableIds ?? ["handle", "turn"]);
573 const { parentId, projectPath } = await saveLocalParentWorkspace(config, rootDir);
574
575 const createWorkspace = mock(
576 async (...args: unknown[]): Promise<Result<{ metadata: WorkspaceMetadata }>> => {
577 const tags = args[7] as Record<string, string> | undefined;
578 await config.editConfig((cfg) => {
579 const project = cfg.projects.get(projectPath);
580 assert(project, "test project must exist");
581 project.workspaces.push({
582 path: path.join(projectPath, "workspace-turn"),
583 id: "childworkspace",
584 name: "workspace-turn",
585 title: "Workspace turn",
586 createdAt: "2026-06-19T00:00:00.000Z",
587 runtimeConfig: { type: "local" },
588 tags,
589 });
590 return cfg;
591 });
592 return Ok({ metadata: createWorkspaceTurnMetadata(projectPath) });
593 }
594 );
595 const workspaceMocks = createWorkspaceServiceMocks({
596 create: createWorkspace,
597 ...(options.sendMessage != null ? { sendMessage: options.sendMessage } : {}),
598 ...(options.remove != null ? { remove: options.remove } : {}),
599 ...(options.hasQueuedMessages != null
600 ? { hasQueuedMessages: options.hasQueuedMessages }
601 : {}),
602 ...(options.hasPendingQueuedOrPreparingTurn != null
603 ? { hasPendingQueuedOrPreparingTurn: options.hasPendingQueuedOrPreparingTurn }
604 : {}),
605 ...(options.waitForPendingStreamErrorRecoveryDecision != null
606 ? {
607 waitForPendingStreamErrorRecoveryDecision:
608 options.waitForPendingStreamErrorRecoveryDecision,
609 }
610 : {}),
611 });
612 const aiMocks = createAIServiceMocks(config, {
613 ...(options.isStreaming != null ? { isStreaming: options.isStreaming } : {}),
614 });
615 const { historyService, taskService } = createTaskServiceHarness(config, {
616 aiService: aiMocks.aiService,

Callers 1

Calls 13

OkFunction · 0.90
stubStableIdsFunction · 0.85
saveLocalParentWorkspaceFunction · 0.85
createAIServiceMocksFunction · 0.85
createTaskServiceHarnessFunction · 0.85
editConfigMethod · 0.80
createWorkspaceTurnMethod · 0.80
createTestConfigFunction · 0.70
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected