Skip to content

Commit 2d538bd

Browse files
authored
Merge f873c30 into 42029a7
2 parents 42029a7 + f873c30 commit 2d538bd

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

test/accessing-reql.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@ describe('accessing-reql', function () {
1313

1414
beforeEach(async () => {
1515
connection = await r.connect(config)
16-
assert(connection.open)
1716
})
1817

1918
afterEach(async () => {
20-
if (!connection.open) {
21-
connection = await r.connect(config)
22-
assert(connection.open)
23-
}
24-
25-
await connection.close()
26-
assert(!connection.open)
19+
if (connection) await connection.close()
2720
})
2821

2922
it('`run` should throw when called without connection', async () => {
@@ -227,7 +220,16 @@ describe('accessing-reql', function () {
227220
{name: 'Mino', grownUp: false}
228221
]).group('grownUp').run(connection, {groupFormat: 'raw'})
229222

230-
assert.deepEqual(result, { '$reql_type$': 'GROUPED_DATA', 'data': [ [ false, [ { 'grownUp': false, 'name': 'Luke' }, { 'grownUp': false, 'name': 'Mino' } ] ], [ true, [ { 'grownUp': true, 'name': 'Michel' }, { 'grownUp': true, 'name': 'Laurent' }, { 'grownUp': true, 'name': 'Sophie' } ] ] ] })
223+
assert.deepEqual(result, {
224+
'$reql_type$': 'GROUPED_DATA',
225+
'data': [[false, [{'grownUp': false, 'name': 'Luke'}, {
226+
'grownUp': false,
227+
'name': 'Mino'
228+
}]], [true, [{'grownUp': true, 'name': 'Michel'}, {'grownUp': true, 'name': 'Laurent'}, {
229+
'grownUp': true,
230+
'name': 'Sophie'
231+
}]]]
232+
})
231233
})
232234

233235
it('`profile` should work', async function () {
@@ -242,23 +244,22 @@ describe('accessing-reql', function () {
242244
assert.equal(result, true)
243245
})
244246

245-
it('`timeout` option should work', async function () {
246-
let server, port
247-
try {
248-
port = Math.floor(Math.random() * (65535 - 1025) + 1025)
249-
250-
server = net.createServer().listen(port)
251-
252-
connection = await r.connect({
247+
it('`timeout` option should work', function (done) {
248+
const port = Math.floor(Math.random() * (65535 - 1025) + 1025)
249+
const server = net.createServer((socket) => {
250+
setTimeout(() => {
251+
socket.destroy()
252+
server.close()
253+
done()
254+
}, 1000)
255+
}).listen(port, () => {
256+
r.connect({
253257
port: port,
254258
timeout: 1
259+
}).error((err) => {
260+
assert.equal(err.message, 'Failed to connect to localhost:' + port + ' in less than 1s.')
255261
})
256-
assert.fail('should throw')
257-
} catch (err) {
258-
await server.close()
259-
260-
assert.equal(err.message, 'Failed to connect to localhost:' + port + ' in less than 1s.')
261-
}
262+
})
262263
})
263264

264265
it('`server` should work', async function () {

test/backtrace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ Expected type NUMBER but found PTYPE<BINARY> in:
29862986
r.binary(<Buffer>).add(1)
29872987
^^^^^^^^^^^^^^^^^^^^^^^^^
29882988
*/
2989-
it('Test backtrace for r.binary(new Buffer([0,1,2,3,4])).add(1)', async () => {
2989+
it('Test backtrace for r.binary(Buffer.from([0,1,2,3,4])).add(1)', async () => {
29902990
try {
29912991
r.nextVarId = 1
29922992
await r.binary(Buffer.from([0, 1, 2, 3, 4])).add(1).run()

0 commit comments

Comments
 (0)