2024-03-21 12:59:49 +01:00
|
|
|
import { IDatabaseRepository } from 'src/interfaces/database.interface';
|
2024-04-16 16:44:45 +02:00
|
|
|
import { Mocked, vitest } from 'vitest';
|
2023-12-21 17:06:26 +01:00
|
|
|
|
2024-04-16 16:44:45 +02:00
|
|
|
export const newDatabaseRepositoryMock = (): Mocked<IDatabaseRepository> => {
|
2023-12-21 17:06:26 +01:00
|
|
|
return {
|
2024-09-04 19:32:43 +02:00
|
|
|
reconnect: vitest.fn(),
|
2024-04-16 16:44:45 +02:00
|
|
|
getExtensionVersion: vitest.fn(),
|
2024-08-06 03:00:25 +02:00
|
|
|
getExtensionVersionRange: vitest.fn(),
|
2024-05-21 02:31:36 +02:00
|
|
|
getPostgresVersion: vitest.fn().mockResolvedValue('14.10 (Debian 14.10-1.pgdg120+1)'),
|
2024-08-06 03:00:25 +02:00
|
|
|
getPostgresVersionRange: vitest.fn().mockReturnValue('>=14.0.0'),
|
2024-05-21 02:31:36 +02:00
|
|
|
createExtension: vitest.fn().mockResolvedValue(void 0),
|
2024-04-16 16:44:45 +02:00
|
|
|
updateExtension: vitest.fn(),
|
|
|
|
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 17:06:26 +01:00
|
|
|
};
|
|
|
|
};
|