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