From a84dce152a3de6a382f997c56441ed571a9833a2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 9 Oct 2024 23:46:48 +0200 Subject: [PATCH] update --- src/connectors/pglite.ts | 5 ++--- test/connectors/pglite.test.ts | 20 +++++++------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/connectors/pglite.ts b/src/connectors/pglite.ts index a4ba7fb..d79e715 100644 --- a/src/connectors/pglite.ts +++ b/src/connectors/pglite.ts @@ -21,9 +21,7 @@ export default function pgliteConnector(opts: ConnectorOptions = {}) { if (_client) { return _client; } - - _client = opts.dataDir ? new PGlite(opts.dataDir, opts) : new PGlite(opts); - + _client = new PGlite(opts); return _client; } @@ -36,6 +34,7 @@ export default function pgliteConnector(opts: ConnectorOptions = {}) { return { name: "pglite", + dialect: "postgresql", exec(sql: string) { return query(sql); }, diff --git a/test/connectors/pglite.test.ts b/test/connectors/pglite.test.ts index c13407c..d832c6d 100644 --- a/test/connectors/pglite.test.ts +++ b/test/connectors/pglite.test.ts @@ -1,22 +1,16 @@ import { fileURLToPath } from "node:url"; -import { existsSync, unlinkSync, mkdirSync } from "node:fs"; +import { rm, mkdir } from "node:fs/promises"; import { dirname, resolve } from "node:path"; import { describe } from "vitest"; import PGlite from "../../src/connectors/pglite" import { testConnector } from "./_tests"; -describe("connectors: pglite", () => { - const dbPath = resolve( - dirname(fileURLToPath(import.meta.url)), - ".tmp/pglite/.data/pglite-data", - ); - if (existsSync(dbPath)) { - unlinkSync(dbPath); - } - mkdirSync(dirname(dbPath), { recursive: true }); +describe("connectors: pglite", async () => { + const dataDir = fileURLToPath(new URL(".tmp/pglite", import.meta.url)); + await rm(dataDir, { recursive: true }).catch(() => { /* */ }); + await mkdir(dirname(dataDir), { recursive: true }); testConnector({ - connector: PGlite({ - dataDir: `${dbPath}`, - }), + dialect: "postgresql", + connector: PGlite({ dataDir }), }); });