()
| 16 | let pool; |
| 17 | |
| 18 | async function init() { |
| 19 | const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST; |
| 20 | const user = USER_FILE ? fs.readFileSync(USER_FILE) : USER; |
| 21 | const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD; |
| 22 | const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; |
| 23 | |
| 24 | await waitPort({ |
| 25 | host, |
| 26 | port: 3306, |
| 27 | timeout: 10000, |
| 28 | waitForDns: true, |
| 29 | }); |
| 30 | |
| 31 | pool = mysql.createPool({ |
| 32 | connectionLimit: 5, |
| 33 | host, |
| 34 | user, |
| 35 | password, |
| 36 | database, |
| 37 | charset: 'utf8mb4', |
| 38 | }); |
| 39 | |
| 40 | return new Promise((acc, rej) => { |
| 41 | pool.query( |
| 42 | 'CREATE TABLE IF NOT EXISTS todo_items (id varchar(36), name varchar(255), completed boolean) DEFAULT CHARSET utf8mb4', |
| 43 | err => { |
| 44 | if (err) return rej(err); |
| 45 | |
| 46 | console.log(`Connected to mysql db at host ${HOST}`); |
| 47 | acc(); |
| 48 | }, |
| 49 | ); |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | async function teardown() { |
| 54 | return new Promise((acc, rej) => { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…