mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
test: update to use kysely-postgres-js
This commit is contained in:
parent
8afc3bca3d
commit
842b527273
1 changed files with 9 additions and 24 deletions
33
src/test.ts
33
src/test.ts
|
|
@ -4,23 +4,17 @@ import path from 'node:path';
|
||||||
import { Database as Sqlite } from '@db/sqlite';
|
import { Database as Sqlite } from '@db/sqlite';
|
||||||
import { DenoSqlite3Dialect } from '@soapbox/kysely-deno-sqlite';
|
import { DenoSqlite3Dialect } from '@soapbox/kysely-deno-sqlite';
|
||||||
import { finalizeEvent, generateSecretKey } from 'nostr-tools';
|
import { finalizeEvent, generateSecretKey } from 'nostr-tools';
|
||||||
import { PostgreSQLDriver } from 'kysely_deno_postgres';
|
|
||||||
import { Pool } from 'postgres';
|
|
||||||
import { NDatabase, NostrEvent } from '@nostrify/nostrify';
|
import { NDatabase, NostrEvent } from '@nostrify/nostrify';
|
||||||
import {
|
import { FileMigrationProvider, Kysely, Migrator } from 'kysely';
|
||||||
FileMigrationProvider,
|
import postgres from 'postgres';
|
||||||
Kysely,
|
import { PostgresJSDialect, PostgresJSDialectConfig } from 'kysely-postgres-js';
|
||||||
Migrator,
|
|
||||||
PostgresAdapter,
|
|
||||||
PostgresIntrospector,
|
|
||||||
PostgresQueryCompiler,
|
|
||||||
} from 'kysely';
|
|
||||||
|
|
||||||
import { DittoDB } from '@/db/DittoDB.ts';
|
import { DittoDB } from '@/db/DittoDB.ts';
|
||||||
import { DittoTables } from '@/db/DittoTables.ts';
|
import { DittoTables } from '@/db/DittoTables.ts';
|
||||||
import { purifyEvent } from '@/storages/hydrate.ts';
|
import { purifyEvent } from '@/storages/hydrate.ts';
|
||||||
import { KyselyLogger } from '@/db/KyselyLogger.ts';
|
import { KyselyLogger } from '@/db/KyselyLogger.ts';
|
||||||
import { EventsDB } from '@/storages/EventsDB.ts';
|
import { EventsDB } from '@/storages/EventsDB.ts';
|
||||||
|
import { Conf } from '@/config.ts';
|
||||||
|
|
||||||
/** Import an event fixture by name in tests. */
|
/** Import an event fixture by name in tests. */
|
||||||
export async function eventFixture(name: string): Promise<NostrEvent> {
|
export async function eventFixture(name: string): Promise<NostrEvent> {
|
||||||
|
|
@ -119,20 +113,11 @@ export const createTestDB = async (databaseUrl?: string) => {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
kysely = new Kysely({
|
kysely = new Kysely({
|
||||||
dialect: {
|
dialect: new PostgresJSDialect({
|
||||||
createAdapter() {
|
postgres: postgres(Conf.databaseUrl, {
|
||||||
return new PostgresAdapter();
|
max: Conf.pg.poolSize,
|
||||||
},
|
}) as unknown as PostgresJSDialectConfig['postgres'],
|
||||||
createDriver() {
|
}),
|
||||||
return new PostgreSQLDriver(new Pool(databaseUrl, 10, true));
|
|
||||||
},
|
|
||||||
createIntrospector(db: Kysely<unknown>) {
|
|
||||||
return new PostgresIntrospector(db);
|
|
||||||
},
|
|
||||||
createQueryCompiler() {
|
|
||||||
return new PostgresQueryCompiler();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
log: KyselyLogger,
|
log: KyselyLogger,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue