()
| 1 | import Database from 'better-sqlite3' |
| 2 | |
| 3 | export function createDurableObjectState(): any { |
| 4 | const db = new Database(':memory:') |
| 5 | |
| 6 | return { |
| 7 | storage: { |
| 8 | sql: { |
| 9 | exec: (query: string, ...bindings: any[]) => { |
| 10 | const method = query.includes('SELECT') || query.includes('RETURNING') ? 'all' : 'run' |
| 11 | const result = db.prepare(query)[method](...bindings) |
| 12 | |
| 13 | if (method === 'all') { |
| 14 | return { |
| 15 | one: () => (result as any)[0], |
| 16 | toArray: () => result, |
| 17 | } |
| 18 | } |
| 19 | }, |
| 20 | }, |
| 21 | }, |
| 22 | waitUntil: vi.fn(), |
| 23 | acceptWebSocket: vi.fn(), |
| 24 | getWebSockets: vi.fn(() => []), |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | export function createCloudflareWebsocket(): any { |
| 29 | let attachment: any = null |
no outgoing calls
no test coverage detected