Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 9, 2024
1 parent 765013f commit a84dce1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/connectors/pglite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -36,6 +34,7 @@ export default function pgliteConnector(opts: ConnectorOptions = {}) {

return <Connector>{
name: "pglite",
dialect: "postgresql",
exec(sql: string) {
return query(sql);
},

Check warning on line 40 in src/connectors/pglite.ts

View check run for this annotation

Codecov / codecov/patch

src/connectors/pglite.ts#L39-L40

Added lines #L39 - L40 were not covered by tests
Expand Down
20 changes: 7 additions & 13 deletions test/connectors/pglite.test.ts
Original file line number Diff line number Diff line change
@@ -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 }),
});
});

0 comments on commit a84dce1

Please sign in to comment.