MCPcopy Index your code
hub / github.com/simstudioai/sim / mockUpsertReturning

Function mockUpsertReturning

apps/sim/lib/logs/execution/snapshot/service.test.ts:385–395  ·  view source on GitHub ↗

Mock the insert → values → onConflictDoUpdate → returning chain.

(rows: SnapshotRow[])

Source from the content-addressed store, hash-verified

383
384 /** Mock the insert → values → onConflictDoUpdate → returning chain. */
385 function mockUpsertReturning(rows: SnapshotRow[]) {
386 let capturedConflictConfig: Record<string, unknown> | undefined
387 const onConflictDoUpdate = vi.fn().mockImplementation((config: Record<string, unknown>) => {
388 capturedConflictConfig = config
389 return { returning: vi.fn().mockResolvedValue(rows) }
390 })
391 const values = vi.fn().mockReturnValue({ onConflictDoUpdate })
392 databaseMock.db.insert = vi.fn().mockReturnValue({ values })
393 databaseMock.db.select = vi.fn()
394 return { values, onConflictDoUpdate, getConflictConfig: () => capturedConflictConfig }
395 }
396
397 it('inserts a new snapshot in a single atomic upsert', async () => {
398 const service = new SnapshotService()

Callers 1

service.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected