2024-03-21 12:59:49 +01:00
|
|
|
import { IDatabaseRepository } from 'src/interfaces/database.interface';
|
2024-03-21 04:15:09 +01:00
|
|
|
import { Version } from 'src/utils/version';
|
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-04-16 16:44:45 +02:00
|
|
|
getExtensionVersion: vitest.fn(),
|
|
|
|
getAvailableExtensionVersion: vitest.fn(),
|
|
|
|
getPreferredVectorExtension: vitest.fn(),
|
|
|
|
getPostgresVersion: vitest.fn().mockResolvedValue(new Version(14, 0, 0)),
|
|
|
|
createExtension: vitest.fn().mockImplementation(() => Promise.resolve()),
|
|
|
|
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
|
|
|
};
|
|
|
|
};
|