2024-03-21 06:59:49 -05:00
|
|
|
import { IDatabaseRepository } from 'src/interfaces/database.interface';
|
2024-03-20 22:15:09 -05:00
|
|
|
import { Version } from 'src/utils/version';
|
2023-12-21 11:06:26 -05:00
|
|
|
|
|
|
|
export const newDatabaseRepositoryMock = (): jest.Mocked<IDatabaseRepository> => {
|
|
|
|
return {
|
|
|
|
getExtensionVersion: jest.fn(),
|
2024-02-06 21:46:38 -05:00
|
|
|
getAvailableExtensionVersion: jest.fn(),
|
|
|
|
getPreferredVectorExtension: jest.fn(),
|
2023-12-21 11:06:26 -05:00
|
|
|
getPostgresVersion: jest.fn().mockResolvedValue(new Version(14, 0, 0)),
|
|
|
|
createExtension: jest.fn().mockImplementation(() => Promise.resolve()),
|
2024-02-06 21:46:38 -05:00
|
|
|
updateExtension: jest.fn(),
|
|
|
|
updateVectorExtension: jest.fn(),
|
|
|
|
reindex: jest.fn(),
|
|
|
|
shouldReindex: jest.fn(),
|
2023-12-21 11:06:26 -05:00
|
|
|
runMigrations: jest.fn(),
|
2024-02-01 22:18:00 -05:00
|
|
|
withLock: jest.fn().mockImplementation((_, function_: <R>() => Promise<R>) => function_()),
|
2024-03-07 12:36:53 -05:00
|
|
|
tryLock: jest.fn(),
|
2023-12-27 18:36:51 -05:00
|
|
|
isBusy: jest.fn(),
|
|
|
|
wait: jest.fn(),
|
2023-12-21 11:06:26 -05:00
|
|
|
};
|
|
|
|
};
|