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

Function withMockCurrentSession

src/utils/model/check1mAccess.test.ts:84–105  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => T,
)

Source from the content-addressed store, hash-verified

82}
83
84function withMockCurrentSession<T>(
85 session: ResolvedAuthSession,
86 fn: () => T,
87): T {
88 const runtime = getAuthRuntime()
89 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
90 ;(
91 runtime as {
92 getCurrentSession: typeof runtime.getCurrentSession
93 }
94 ).getCurrentSession = () => session
95
96 try {
97 return fn()
98 } finally {
99 ;(
100 runtime as {
101 getCurrentSession: typeof runtime.getCurrentSession
102 }
103 ).getCurrentSession = originalGetCurrentSession
104 }
105}
106
107beforeEach(() => {
108 process.env.CLAUDE_CODE_ENTRYPOINT = 'cli'

Callers 1

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected