MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / createMockContext

Function createMockContext

services/db-proxy/src/utils/auth.test.ts:13–28  ·  view source on GitHub ↗
(env: Partial<Env> = {})

Source from the content-addressed store, hash-verified

11
12// Mock Hono Context
13function createMockContext(env: Partial<Env> = {}): Context<{ Bindings: Env }> {
14 const headerMock = jest.fn((name: string) => {
15 if (name === 'Authorization') return undefined;
16 return undefined;
17 });
18 return {
19 req: {
20 header: headerMock,
21 },
22 env: {
23 DB_PROXY_ADMIN_TOKEN: env.DB_PROXY_ADMIN_TOKEN ?? 'test-admin-token',
24 } as Env,
25 json: (body: unknown, status?: number) =>
26 new Response(JSON.stringify(body), { status: status ?? 200 }),
27 } as unknown as Context<{ Bindings: Env }>;
28}
29
30describe('auth utilities', () => {
31 describe('extractBearerToken', () => {

Callers 1

auth.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected