(options: SetupParams)
| 9 | } |
| 10 | |
| 11 | export async function setupMysql(options: SetupParams): Promise<void> { |
| 12 | const { connectionString } = options |
| 13 | const { dirname } = options |
| 14 | const schema = fs.readFileSync(path.join(dirname, 'setup.sql'), 'utf-8') |
| 15 | |
| 16 | await createDatabase(connectionString).catch((e) => console.error(e)) |
| 17 | |
| 18 | const credentials = uriToCredentials(connectionString) |
| 19 | const db = await mariadb.createConnection({ |
| 20 | host: credentials.host, |
| 21 | port: credentials.port, |
| 22 | database: credentials.database, |
| 23 | user: credentials.user, |
| 24 | password: credentials.password, |
| 25 | multipleStatements: true, |
| 26 | allowPublicKeyRetrieval: true, |
| 27 | }) |
| 28 | |
| 29 | await db.query(schema) |
| 30 | await db.end() |
| 31 | } |
| 32 | |
| 33 | export async function tearDownMysql(connectionString: string) { |
| 34 | const credentials = uriToCredentials(connectionString) |
no test coverage detected