Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move column ordering test

  • Loading branch information...
commit baed417e87b6b9bbf825a6645475f3e73567f8f1 1 parent b1774fc
@felixge felixge authored
View
36 test/integration/Query/misc/test-column-ordering.js
@@ -0,0 +1,36 @@
+var common = require('../../../common');
+var assert = require('assert');
+var fs = require('fs');
+var mysql = require(common.dir.root);
+var REPEATS = 500;
+
+var client = common.createClient();
+client.query('CREATE DATABASE ' + common.TEST_DB, function(err) {
+ if (err && err.number != mysql.ERROR_DB_CREATE_EXISTS) throw err;
+});
+client.query('USE ' + common.TEST_DB);
+
+client.query('DROP TABLE IF EXISTS columnia');
+var fixture = fs.readFileSync(common.dir.fixture + '/columnia.sql', 'utf8');
+client.query(fixture);
+
+var finished = 0;
+var self = this;
+for (var i = 0; i < REPEATS; i++) {
+ (function(i) {
+ var query = client.query("SHOW COLUMNS FROM columnia");
+
+ query.on('row', function(row) {
+ if (!row.Type) throw new Error('Column order mixed up after '+i+' queries.');
+ });
+
+ query.on('end', function() {
+ finished++;
+ if (finished === REPEATS) client.destroy();
+ });
+ })(i);
+}
+
+process.on('exit', function() {
+ assert.equal(finished, REPEATS);
+});
View
50 test/integration/test-client-query-column-ordering.js
@@ -1,50 +0,0 @@
-var common = require('../common');
-var assert = require('assert');
-var test = common.fastOrSlow.slow();
-var mysql = require(common.dir.lib + '/mysql');
-var fs = require('fs');
-
-test.before(function() {
- this.client = common.createClient();
-});
-
-test.after(function(done) {
- this.client.end(done);
-});
-
-test('Column ordering works properly', {timeout: 15 * 1000}, function(done) {
- var REPEATS = 500;
-
- this.client.query('CREATE DATABASE ' + common.TEST_DB, function(err) {
- if (err && err.number != mysql.ERROR_DB_CREATE_EXISTS) {
- throw err;
- }
- });
- this.client.query('USE ' + common.TEST_DB);
-
- this.client.query('DROP TABLE IF EXISTS columnia');
- var fixture = fs.readFileSync(common.dir.fixture + '/columnia.sql', 'utf8');
- this.client.query(fixture);
-
- var finished = 0;
- var self = this;
- for (var i = 0; i < REPEATS; i++) {
- (function(i) {
- var query = self.client.query("SHOW COLUMNS FROM columnia");
-
- query.on('row', function(row) {
- if (!row.Type) {
- throw new Error('Column order mixed up after '+i+' queries.');
- }
- });
-
- query.on('end', function() {
- finished++;
- if (finished === REPEATS) {
- done();
- }
- });
- })(i);
- }
-});
-
Please sign in to comment.
Something went wrong with that request. Please try again.