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

Function withMockCurrentSession

src/services/api/withRetry.test.ts:198–219  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => Promise<T> | T,
)

Source from the content-addressed store, hash-verified

196}
197
198async function withMockCurrentSession<T>(
199 session: ResolvedAuthSession,
200 fn: () => Promise<T> | T,
201): Promise<T> {
202 const runtime = getAuthRuntime()
203 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
204 ;(
205 runtime as {
206 getCurrentSession: typeof runtime.getCurrentSession
207 }
208 ).getCurrentSession = () => session
209
210 try {
211 return await fn()
212 } finally {
213 ;(
214 runtime as {
215 getCurrentSession: typeof runtime.getCurrentSession
216 }
217 ).getCurrentSession = originalGetCurrentSession
218 }
219}
220
221beforeAll(async () => {
222 tempConfigDir = await mkdtemp(join(tmpdir(), 'ncode-with-retry-test-'))

Callers 1

withRetry.test.tsFile · 0.70

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected