Skip to content

Commit 9af968f

Browse files
committed
Split connection tests up again
1 parent cb139f4 commit 9af968f

6 files changed

+111
-94
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var common = require('../../../common');
2+
var assert = require('assert');
3+
4+
var client = common.createClient();
5+
client.query('SELECT 1', function(err, results) {
6+
if (err) throw err;
7+
8+
assert.deepEqual(results, [{1: 1}]);
9+
10+
client.end();
11+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var common = require('../../../common');
2+
var assert = require('assert');
3+
4+
var client = common.createClient();
5+
// Not sure if we need all 3 of these, but they do the trick
6+
client.query('SET interactive_timeout = 1');
7+
client.query('SET wait_timeout = 1');
8+
client.query('SET net_read_timeout = 1');
9+
10+
var result;
11+
client._socket.on('end', function() {
12+
assert.equal(client.connected, false);
13+
14+
client.query('SELECT 1', function(err, _result) {
15+
if (err) throw err;
16+
17+
result = _result;
18+
client.destroy();
19+
});
20+
});
21+
22+
process.on('exit', function() {
23+
assert.deepEqual(result, [{'1': 1}]);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var common = require('../../../common');
2+
var assert = require('assert');
3+
4+
var client = common.createClient();
5+
client.password = 'thispassworddoesnotreallywork';
6+
7+
var callbacks = [];
8+
client.query('SELECT 1', function(err) {
9+
assert.ok(/access denied/i.test(err.message));
10+
11+
callbacks.push(1);
12+
});
13+
14+
client.query('SELECT 2', function(err) {
15+
assert.ok(/access denied/i.test(err.message));
16+
17+
callbacks.push(2);
18+
19+
client.destroy();
20+
});
21+
22+
process.on('exit', function() {
23+
assert.deepEqual(callbacks, [1, 2]);
24+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var common = require('../../../common');
2+
var assert = require('assert');
3+
4+
var client = common.createClient();
5+
// Port number outside of range -> triggers connection error
6+
client.port = 999999999;
7+
8+
var callbacks = [];
9+
client.query('SELECT 1', function(err) {
10+
assert.ok(err);
11+
12+
callbacks.push(1);
13+
});
14+
15+
client.query('SELECT 2', function(err) {
16+
assert.ok(err);
17+
18+
callbacks.push(2);
19+
20+
client.destroy();
21+
});
22+
23+
process.on('exit', function() {
24+
assert.deepEqual(callbacks, [1, 2]);
25+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var common = require('../../../common');
2+
var assert = require('assert');
3+
4+
var client = common.createClient();
5+
var callbacks = [];
6+
client.query('SELECT 1', function(err, results) {
7+
if (err) throw err;
8+
9+
callbacks.push(1);
10+
});
11+
12+
client.end(function(err) {
13+
if (err) throw err;
14+
15+
callbacks.push(2);
16+
});
17+
18+
client.query('SELECT 1', function(err) {
19+
if (err) throw err;
20+
21+
callbacks.push(3);
22+
client.destroy();
23+
});
24+
25+
process.on('exit', function() {
26+
assert.deepEqual(callbacks, [1, 2, 3]);
27+
});

test/integration/test-client-connect.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy