( session: ResolvedAuthSession, fn: () => Promise<T> | T, )
| 196 | } |
| 197 | |
| 198 | async 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 | |
| 221 | beforeAll(async () => { |
| 222 | tempConfigDir = await mkdtemp(join(tmpdir(), 'ncode-with-retry-test-')) |
no test coverage detected