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

Function withMockCurrentSession

src/utils/effort.auth.test.ts:61–82  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => T,
)

Source from the content-addressed store, hash-verified

59}
60
61function withMockCurrentSession<T>(
62 session: ResolvedAuthSession,
63 fn: () => T,
64): T {
65 const runtime = getAuthRuntime()
66 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
67 ;(
68 runtime as {
69 getCurrentSession: typeof runtime.getCurrentSession
70 }
71 ).getCurrentSession = () => session
72
73 try {
74 return fn()
75 } finally {
76 ;(
77 runtime as {
78 getCurrentSession: typeof runtime.getCurrentSession
79 }
80 ).getCurrentSession = originalGetCurrentSession
81 }
82}
83
84const originalBuildMode = process.env.NCODE_BUILD_MODE
85const originalUserType = process.env.USER_TYPE

Callers 1

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected