fix(db): under mac and linux using alternative pool mechanism

this must fix test brokeup and closing stub
This commit is contained in:
Alexey Kasyanchuk
2018-08-07 17:21:46 +03:00
parent 725632e709
commit 297baac3d3
5 changed files with 96 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import { expect } from "chai";
import { expect, assert } from "chai";
const mysql = require('mysql')
const config = require('../src/background/config')
@ -60,15 +60,29 @@ describe("sphinx", () => {
})
})
it("query limit", function(done) {
const sphinx = pool()
let promises = []
sphinx.query(`delete from feed where id >= 0`, () => {
for(let i = 0; i < 500; i++)
promises.push(sphinx.query(`insert into feed(id, data) values(${i}, 'a')`))
Promise.all(promises).then(() => {
sphinx.query(`delete from feed where id >= 0`, () => done())
it("query limit", function(done) {
const test = async () => {
const sphinx = await pool()
let promises = []
sphinx.query(`delete from feed where id >= 0`, () => {
for(let i = 0; i < 500; i++)
promises.push(sphinx.query(`insert into feed(id, data) values(${i}, 'a')`))
Promise.all(promises).then(() => {
sphinx.query(`delete from feed where id >= 0`, async () => {
await sphinx.end()
done()
})
})
})
})
}
test()
})
it("escape", function () {
assert.equal(sphinx.escape(`naru'to`), `'naru\\'to'`)
})
it("close pool", function(done) {
sphinx.end(done)
})
});