MCPcopy
hub / github.com/CodebuffAI/codebuff / createDbMock

Function createDbMock

packages/billing/src/__tests__/org-billing.test.ts:52–85  ·  view source on GitHub ↗
(options?: {
  grants?: typeof mockGrants | any[]
  insert?: () => { values: () => { onConflictDoNothing: () => { returning: () => Promise<unknown[]> } } }
  update?: () => { set: () => { where: () => Promise<unknown> } }
})

Source from the content-addressed store, hash-verified

50}
51
52const createDbMock = (options?: {
53 grants?: typeof mockGrants | any[]
54 insert?: () => { values: () => { onConflictDoNothing: () => { returning: () => Promise<unknown[]> } } }
55 update?: () => { set: () => { where: () => Promise<unknown> } }
56}) => {
57 const { grants = mockGrants, insert, update } = options ?? {}
58
59 return {
60 select: () => ({
61 from: () => ({
62 where: () => ({
63 orderBy: () => grants,
64 }),
65 }),
66 }),
67 insert:
68 insert ??
69 (() => ({
70 values: () => ({
71 onConflictDoNothing: () => ({
72 returning: () => Promise.resolve([{ id: 'test-id' }]),
73 }),
74 }),
75 })),
76 update:
77 update ??
78 (() => ({
79 set: () => ({
80 where: () => Promise.resolve(),
81 }),
82 })),
83 execute: () => Promise.resolve([]),
84 }
85}
86
87describe('Organization Billing', () => {
88 beforeEach(async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected