MCPcopy Create free account
hub / github.com/Effect-TS/effect / dumpConnection

Function dumpConnection

packages/sql/pg/test/PgMigrator.test.ts:60–68  ·  view source on GitHub ↗
(command: ChildProcess.StandardCommand)

Source from the content-addressed store, hash-verified

58
59// Parses the libpq conninfo passed as `pg_dump --dbname=<conninfo>`.
60const dumpConnection = (command: ChildProcess.StandardCommand) => {
61 const dbname = command.args.find((arg): arg is string => typeof arg === "string" && arg.startsWith("--dbname="))
62 assert(dbname !== undefined, "pg_dump was not given --dbname")
63 const conninfo: Record<string, string> = {}
64 for (const [, key, quoted, plain] of dbname.slice(9).matchAll(/(\w+)\s*=\s*(?:'((?:[^'\\]|\\.)*)'|(\S*))/g)) {
65 conninfo[key] = quoted !== undefined ? quoted.replace(/\\(.)/g, "$1") : plain
66 }
67 return conninfo
68}
69
70describe("PgMigrator", () => {
71 it.effect("shares one password per schema dump and refreshes it for the next dump", () =>

Callers 2

PgMigrator.test.tsFile · 0.85
dumpSchemaFunction · 0.85

Calls 4

sliceMethod · 0.80
findMethod · 0.65
assertFunction · 0.50
replaceMethod · 0.45

Tested by

no test coverage detected