Skip to content

tests: converge the three same-interface createMockFileSystem() helpers (divergent defaults) #742

Description

@debugmcpdev

Follow-up from #739 / #741, which made tests/test-utils/helpers/test-utils.ts's createMockFileSystem() honest (no as any, all 16 IFileSystem members) but deliberately did not converge the four definitions that exist. They differ in ways their consumers rely on, so this is a ticket rather than a ride-along:

Definition Type Defaults Consumers
tests/test-utils/helpers/test-utils.ts @debugmcp/shared IFileSystem, no cast pre-configured: pathExiststrue, existsSynctrue, ensureDirundefined, readTail/readFile'', stat{isDirectory:()=>false,isFile:()=>true}, … 5 SessionManager-layer suites (proxy-failure-diagnostics, session-manager-attach-modes, -launch-gate, session-manager-test-utils, session-manager-operations-coverage); three carry a comment relying on pathExiststrue
tests/test-utils/helpers/test-dependencies.ts:63 same interface, no cast none — every member a bare vi.fn() proxy-manager-factory.test.ts, proxy-manager-message-handling.test.ts, and createMockDependencies()
tests/test-utils/helpers/adapter-dependencies.ts:33 same interface, (overrides: Partial<IFileSystem> = {}) exists/pathExists/existsSync→**false**, spreads overrides tests/unit/test-utils/test-proxy-manager.ts (aliased createTypedMockFileSystem)
tests/test-utils/mocks/dap-proxy-doubles.ts the worker-local four-member IFileSystem in src/proxy/dap-proxy-interfaces.ts proxy-worker + go-initialized-fallback tests

The fourth is a different interface on purpose (a wide double would hide a member the worker starts calling) and should stay. The first three are the same interface with three default policies: "everything exists", "nothing answers", "nothing exists + overrides". Consolidating onto any one of them silently changes what the other two's consumers see — test-dependencies.ts's bare version would break the three suites that rely on pathExiststrue; adapter-dependencies.ts's false default would too.

Suggested shape: one createMockFileSystem(overrides?: Partial<IFileSystem>) with the "everything exists" defaults (the majority case) in helpers/test-dependencies.ts, createMockDependencies() using it, and the two other files re-exporting or deleted; the test-proxy-manager.ts caller passes { pathExists: vi.fn().mockResolvedValue(false), … } explicitly where it needs the negative. Gate: npx tsc -p tsconfig.spec.json silent and every listed consumer green in isolation.

Same class as #695 / #739 (drifted or duplicated test doubles).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions