* Wires `db.select` to return a single active deployment-version row for the * given id. Returns the inner `where` spy so tests can assert how many times * the active-version SELECT ran.
(versionId: string, state: unknown)
| 1622 | * the active-version SELECT ran. |
| 1623 | */ |
| 1624 | function mockActiveVersionSelect(versionId: string, state: unknown) { |
| 1625 | const where = vi.fn().mockReturnValue({ |
| 1626 | orderBy: vi.fn().mockReturnValue({ |
| 1627 | limit: vi.fn().mockResolvedValue([{ id: versionId, state, createdAt: new Date() }]), |
| 1628 | }), |
| 1629 | }) |
| 1630 | mockDb.select.mockReturnValue({ |
| 1631 | from: vi.fn().mockReturnValue({ where }), |
| 1632 | }) |
| 1633 | return where |
| 1634 | } |
| 1635 | |
| 1636 | beforeEach(() => { |
| 1637 | vi.clearAllMocks() |