(rows: EventRow[])
| 29 | }) |
| 30 | |
| 31 | const createMockDb = (rows: EventRow[]) => { |
| 32 | const makeQuery = () => ({ |
| 33 | select() { |
| 34 | return this |
| 35 | }, |
| 36 | whereNull() { |
| 37 | return this |
| 38 | }, |
| 39 | orderBy() { |
| 40 | return this |
| 41 | }, |
| 42 | first: async () => (rows[0] ? { event_id: rows[0].event_id } : undefined), |
| 43 | stream: () => Readable.from(rows), |
| 44 | }) |
| 45 | |
| 46 | const db = ((table: string) => { |
| 47 | if (table !== 'events') { |
| 48 | throw new Error(`Unexpected table: ${table}`) |
| 49 | } |
| 50 | |
| 51 | return makeQuery() |
| 52 | }) as unknown as ((table: string) => ReturnType<typeof makeQuery>) & { destroy: () => Promise<void> } |
| 53 | |
| 54 | db.destroy = async () => {} |
| 55 | return db |
| 56 | } |
| 57 | |
| 58 | describe('cli export formats', () => { |
| 59 | afterEach(() => { |
no test coverage detected