Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import test from 'ava'
- import mysql from 'mysql1'
- const pool = mysql.createPool({
- connectionLimit: 10,
- host: 'localhost',
- user: 'root',
- port: 3306,
- database: 'test',
- password: '',
- })
- const foo = () => new Promise((resolve) => {
- resolve(1)
- })
- const multiQuery = () => new Promise((resolve, reject) => {
- const sql = `
- SELECT GET_LOCK('test2', -1) AS test3;
- `
- pool.query(sql, (err, res) => (err == null ? resolve(res) : reject(err)))
- })
- test(async (t) => {
- const response = await multiQuery()
- console.log(response)
- t.is(await foo(), 1)
- })
Add Comment
Please, Sign In to add comment