Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Aug 31, 2010
1 parent 3406bc6 commit c61d471
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/mysql/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Client(config) {
this.port = 3306;
this.user = null;
this.password = null;
this.database = null;
this.database = '';

this.flags = Client.defaultFlags;
this.maxPacketSize = 0x01000000;
Expand Down
4 changes: 2 additions & 2 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ var path = require('path')

require.paths.unshift(path.dirname(__dirname)+'/lib');

global.TEST_DB = 'node_mysql_test';
global.TEST_CONFIG = {
host: 'localhost',
port: 3306,
user: 'root',
password: 'root',
database: 'node_mysql_test',
password: 'root'
};

global.TEST_TABLE = 'posts';
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test(function constructor() {
assert.strictEqual(client.port, 3306);
assert.strictEqual(client.user, null);
assert.strictEqual(client.password, null);
assert.strictEqual(client.database, null);
assert.strictEqual(client.database, '');

assert.strictEqual(client.debug, false);

Expand Down
Binary file added test/system/.test-client-connect.js.un~
Binary file not shown.
Binary file not shown.
Binary file added test/system/.test-client-query-empty.js.un~
Binary file not shown.
Binary file added test/system/.test-client-query-long-fields.js.un~
Binary file not shown.
Binary file added test/system/.test-client-query-null.js.un~
Binary file not shown.
Binary file added test/system/.test-client-query.js.un~
Binary file not shown.
Binary file added test/system/.test-client-sequential-query.js.un~
Binary file not shown.
9 changes: 3 additions & 6 deletions test/system/test-client-connect.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
require('../common');
var client = require('mysql').Client(TEST_CONFIG)
, gently = new Gently();

// our test db does not exist yet, so don't try to connect to it
client.database = '';
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

client.connect(gently.expect(function connectCb(err, result) {
if (err) throw err;

assert.strictEqual(result.affectedRows, 0);
client.end();
}));
}));
5 changes: 1 addition & 4 deletions test/system/test-client-query-calculated-fields.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require('../common');
var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.database = '';
client.connect();

client.query('SELECT 1 as field_a, 2 as field_b', function(err, results) {
Expand Down
5 changes: 1 addition & 4 deletions test/system/test-client-query-empty.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require('../common');
var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.database = '';
client.connect();

client.query('SELECT "" as field_a', function(err, results) {
Expand Down
4 changes: 1 addition & 3 deletions test/system/test-client-query-long-fields.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require('../common');
var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.connect();

function makeString(length) {
Expand Down
5 changes: 1 addition & 4 deletions test/system/test-client-query-null.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require('../common');
var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.database = '';
client.connect();

client.query('SELECT NULL as field_a, NULL as field_b', function(err, results) {
Expand Down
7 changes: 2 additions & 5 deletions test/system/test-client-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.database = '';

client.connect();

client.query(
'CREATE DATABASE '+TEST_CONFIG.database,
'CREATE DATABASE '+TEST_DB,
gently.expect(function createDbCb(err) {
if (err && err.number != Client.ERROR_DB_CREATE_EXISTS) {
throw err;
Expand All @@ -18,7 +15,7 @@ client.query(
);

client.query(
'USE '+TEST_CONFIG.database,
'USE '+TEST_DB,
gently.expect(function useDbCb(err) {
if (err) {
throw err;
Expand Down
5 changes: 1 addition & 4 deletions test/system/test-client-sequential-query.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require('../common');
var Client = require('mysql').Client,
client = Client(TEST_CONFIG),
var client = require('mysql').Client(TEST_CONFIG),
gently = new Gently();

// our test db might not exist yet, so don't try to connect to it
client.database = '';
client.connect();

client.query('SELECT 1 as field_a, 2 as field_b', function(err, results) {
Expand Down

0 comments on commit c61d471

Please sign in to comment.