MCPcopy
hub / github.com/simstudioai/sim / createMockSqlOperators

Function createMockSqlOperators

packages/testing/src/mocks/database.mock.ts:36–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 * Creates mock SQL operators (eq, and, or, etc.).
35 */
36export function createMockSqlOperators() {
37 return {
38 eq: vi.fn((a, b) => ({ type: 'eq', left: a, right: b })),
39 ne: vi.fn((a, b) => ({ type: 'ne', left: a, right: b })),
40 gt: vi.fn((a, b) => ({ type: 'gt', left: a, right: b })),
41 gte: vi.fn((a, b) => ({ type: 'gte', left: a, right: b })),
42 lt: vi.fn((a, b) => ({ type: 'lt', left: a, right: b })),
43 lte: vi.fn((a, b) => ({ type: 'lte', left: a, right: b })),
44 count: vi.fn((column) => ({ type: 'count', column })),
45 avg: vi.fn((column) => ({ type: 'avg', column })),
46 sum: vi.fn((column) => ({ type: 'sum', column })),
47 min: vi.fn((column) => ({ type: 'min', column })),
48 max: vi.fn((column) => ({ type: 'max', column })),
49 and: vi.fn((...conditions) => ({ type: 'and', conditions })),
50 or: vi.fn((...conditions) => ({ type: 'or', conditions })),
51 not: vi.fn((condition) => ({ type: 'not', condition })),
52 isNull: vi.fn((column) => ({ type: 'isNull', column })),
53 isNotNull: vi.fn((column) => ({ type: 'isNotNull', column })),
54 inArray: vi.fn((column, values) => ({ type: 'inArray', column, values })),
55 notInArray: vi.fn((column, values) => ({ type: 'notInArray', column, values })),
56 exists: vi.fn((subquery) => ({ type: 'exists', subquery })),
57 notExists: vi.fn((subquery) => ({ type: 'notExists', subquery })),
58 like: vi.fn((column, pattern) => ({ type: 'like', column, pattern })),
59 ilike: vi.fn((column, pattern) => ({ type: 'ilike', column, pattern })),
60 desc: vi.fn((column) => ({ type: 'desc', column })),
61 asc: vi.fn((column) => ({ type: 'asc', column })),
62 }
63}
64
65/**
66 * Pre-wired chain of vi.fn()s for drizzle-style DB queries.

Callers 1

database.mock.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected