2024-03-21 11:59:49 +00:00
|
|
|
import { IDatabaseRepository } from 'src/interfaces/database.interface';
|
2024-04-16 14:44:45 +00:00
|
|
|
import { Mocked, vitest } from 'vitest';
|
2023-12-21 16:06:26 +00:00
|
|
|
|
2024-04-16 14:44:45 +00:00
|
|
|
export const newDatabaseRepositoryMock = (): Mocked<IDatabaseRepository> => {
|
2023-12-21 16:06:26 +00:00
|
|
|
return {
|
2024-09-04 17:32:43 +00:00
|
|
|
reconnect: vitest.fn(),
|
2024-04-16 14:44:45 +00:00
|
|
|
getExtensionVersion: vitest.fn(),
|
2024-08-06 01:00:25 +00:00
|
|
|
getExtensionVersionRange: vitest.fn(),
|
2024-05-21 00:31:36 +00:00
|
|
|
getPostgresVersion: vitest.fn().mockResolvedValue('14.10 (Debian 14.10-1.pgdg120+1)'),
|
2024-08-06 01:00:25 +00:00
|
|
|
getPostgresVersionRange: vitest.fn().mockReturnValue('>=14.0.0'),
|
2024-05-21 00:31:36 +00:00
|
|
|
createExtension: vitest.fn().mockResolvedValue(void 0),
|
2024-04-16 14:44:45 +00:00
|
|
|
updateVectorExtension: vitest.fn(),
|
|
|
|
reindex: vitest.fn(),
|
|
|
|
shouldReindex: vitest.fn(),
|
|
|
|
runMigrations: vitest.fn(),
|
|
|
|
withLock: vitest.fn().mockImplementation((_, function_: <R>() => Promise<R>) => function_()),
|
|
|
|
tryLock: vitest.fn(),
|
|
|
|
isBusy: vitest.fn(),
|
|
|
|
wait: vitest.fn(),
|
2023-12-21 16:06:26 +00:00
|
|
|
};
|
|
|
|
};
|