MCPcopy Create free account
hub / github.com/Noumena-Network/code / withMockCurrentSession

Function withMockCurrentSession

src/utils/planModeV2.test.ts:55–76  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => T,
)

Source from the content-addressed store, hash-verified

53}
54
55function withMockCurrentSession<T>(
56 session: ResolvedAuthSession,
57 fn: () => T,
58): T {
59 const runtime = getAuthRuntime()
60 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
61 ;(
62 runtime as {
63 getCurrentSession: typeof runtime.getCurrentSession
64 }
65 ).getCurrentSession = () => session
66
67 try {
68 return fn()
69 } finally {
70 ;(
71 runtime as {
72 getCurrentSession: typeof runtime.getCurrentSession
73 }
74 ).getCurrentSession = originalGetCurrentSession
75 }
76}
77
78beforeEach(() => {
79 delete process.env.CLAUDE_CODE_PLAN_V2_AGENT_COUNT

Callers 1

planModeV2.test.tsFile · 0.70

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected