(connectionString: string)
| 25 | } |
| 26 | |
| 27 | export async function tearDownPostgres(connectionString: string) { |
| 28 | const credentials = uriToCredentials(connectionString) |
| 29 | const credentialsClone = { ...credentials } |
| 30 | credentialsClone.database = 'postgres' |
| 31 | credentialsClone.schema = '' |
| 32 | const connectionStringCopy = credentialsToUri(credentialsClone) |
| 33 | |
| 34 | const db = new Client({ |
| 35 | connectionString: connectionStringCopy, |
| 36 | }) |
| 37 | |
| 38 | try { |
| 39 | await db.connect() |
| 40 | await db.query(` |
| 41 | DROP DATABASE IF EXISTS "${credentials.database}"; |
| 42 | `) |
| 43 | } catch (e) { |
| 44 | console.error(e) |
| 45 | } |
| 46 | await db.end() |
| 47 | } |
no test coverage detected