MCPcopy Index your code
hub / github.com/cameri/nostream / createMockDb

Function createMockDb

test/unit/cli/export.spec.ts:31–56  ·  view source on GitHub ↗
(rows: EventRow[])

Source from the content-addressed store, hash-verified

29})
30
31const 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
58describe('cli export formats', () => {
59 afterEach(() => {

Callers 1

export.spec.tsFile · 0.85

Calls 1

makeQueryFunction · 0.85

Tested by

no test coverage detected