(
selectedFinding = finding,
options: {
failAuditInsert?: boolean;
actor?: { id: string; email: string; name: string; isAdmin: boolean };
} = {}
)
| 28 | fixed_at: null, |
| 29 | sla_due_at: '2026-05-24 08:30:00.000+00', |
| 30 | session_id: null, |
| 31 | owned_by_organization_id: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa', |
| 32 | owned_by_user_id: null, |
| 33 | platform_integration_id: 'cccccccc-cccc-4ccc-8ccc-cccccccccccc', |
| 34 | }; |
| 35 | |
| 36 | function createDb( |
| 37 | selectedFinding: Omit<typeof finding, 'platform_integration_id'> & { |
| 38 | platform_integration_id: string | null; |
| 39 | } = finding, |
| 40 | options: { |
| 41 | failAuditInsert?: boolean; |
| 42 | actor?: { id: string; email: string; name: string; isAdmin: boolean }; |
| 43 | integrations?: { |
| 44 | id: string; |
| 45 | installationId: string; |
| 46 | githubAppType: 'standard' | 'lite'; |
| 47 | hasRepositoryAccess: boolean; |
| 48 | hasWritePermission: boolean; |
| 49 | }[]; |
| 50 | } = {} |
| 51 | ) { |
| 52 | const updates: unknown[] = []; |
| 53 | const auditRows: unknown[] = []; |
| 54 | let selectCount = 0; |
| 55 | const actor = options.actor ?? { |
| 56 | id: 'user-123', |
| 57 | email: 'owner@example.com', |
| 58 | name: 'Owner Example', |
| 59 | isAdmin: false, |
| 60 | }; |
| 61 | function createOperations(targetUpdates: unknown[], targetAuditRows: unknown[]) { |
| 62 | return { |
| 63 | update: () => ({ |
| 64 | set: (values: unknown) => ({ |
| 65 | where: async () => { |
| 66 | targetUpdates.push(values); |
| 67 | }, |
| 68 | }), |
| 69 | }), |
| 70 | insert: () => ({ |
| 71 | values: (values: unknown) => ({ |
| 72 | onConflictDoNothing: () => ({ |
| 73 | returning: async () => { |
| 74 | if (options.failAuditInsert) { |
| 75 | throw new Error('audit insert failed'); |
| 76 | } |
| 77 | targetAuditRows.push(values); |
| 78 | return [{ id: 'audit-row-1' }]; |
| 79 | }, |
| 80 | }), |
| 81 | }), |
| 82 | }), |
| 83 | }; |
| 84 | } |
| 85 | const db = { |
| 86 | select: () => ({ |
| 87 | from: () => ({ |
no test coverage detected