mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: medium tests for user and sync service (#16304)
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
parent
ae61ea7984
commit
7c851893b4
15 changed files with 634 additions and 24 deletions
61
server/test/medium/globalSetup.ts
Normal file
61
server/test/medium/globalSetup.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { GenericContainer, Wait } from 'testcontainers';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const globalSetup = async () => {
|
||||
const postgres = await new GenericContainer('tensorchord/pgvecto-rs:pg14-v0.2.0')
|
||||
.withExposedPorts(5432)
|
||||
.withEnvironment({
|
||||
POSTGRES_PASSWORD: 'postgres',
|
||||
POSTGRES_USER: 'postgres',
|
||||
POSTGRES_DB: 'immich',
|
||||
})
|
||||
.withCommand([
|
||||
'postgres',
|
||||
'-c',
|
||||
'shared_preload_libraries=vectors.so',
|
||||
'-c',
|
||||
'search_path="$$user", public, vectors',
|
||||
'-c',
|
||||
'max_wal_size=2GB',
|
||||
'-c',
|
||||
'shared_buffers=512MB',
|
||||
'-c',
|
||||
'fsync=off',
|
||||
'-c',
|
||||
'full_page_writes=off',
|
||||
'-c',
|
||||
'synchronous_commit=off',
|
||||
])
|
||||
.withWaitStrategy(Wait.forAll([Wait.forLogMessage('database system is ready to accept connections', 2)]))
|
||||
.start();
|
||||
|
||||
const postgresPort = postgres.getMappedPort(5432);
|
||||
const postgresUrl = `postgres://postgres:postgres@localhost:${postgresPort}/immich`;
|
||||
process.env.IMMICH_TEST_POSTGRES_URL = postgresUrl;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
const modules = import.meta.glob('/src/migrations/*.ts', { eager: true });
|
||||
|
||||
const config = {
|
||||
type: 'postgres' as const,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
migrations: Object.values(modules).map((module) => Object.values(module)[0]),
|
||||
migrationsRun: false,
|
||||
synchronize: false,
|
||||
connectTimeoutMS: 10_000, // 10 seconds
|
||||
parseInt8: true,
|
||||
url: postgresUrl,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
const dataSource = new DataSource(config);
|
||||
await dataSource.initialize();
|
||||
await dataSource.query('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"');
|
||||
await dataSource.runMigrations();
|
||||
await dataSource.destroy();
|
||||
};
|
||||
|
||||
export default globalSetup;
|
||||
Loading…
Add table
Add a link
Reference in a new issue