Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move column ordering test

  • Loading branch information...
commit baed417e87b6b9bbf825a6645475f3e73567f8f1 1 parent b1774fc
Felix Geisendörfer felixge authored
36 test/integration/Query/misc/test-column-ordering.js
... ... @@ -0,0 +1,36 @@
  1 +var common = require('../../../common');
  2 +var assert = require('assert');
  3 +var fs = require('fs');
  4 +var mysql = require(common.dir.root);
  5 +var REPEATS = 500;
  6 +
  7 +var client = common.createClient();
  8 +client.query('CREATE DATABASE ' + common.TEST_DB, function(err) {
  9 + if (err && err.number != mysql.ERROR_DB_CREATE_EXISTS) throw err;
  10 +});
  11 +client.query('USE ' + common.TEST_DB);
  12 +
  13 +client.query('DROP TABLE IF EXISTS columnia');
  14 +var fixture = fs.readFileSync(common.dir.fixture + '/columnia.sql', 'utf8');
  15 +client.query(fixture);
  16 +
  17 +var finished = 0;
  18 +var self = this;
  19 +for (var i = 0; i < REPEATS; i++) {
  20 + (function(i) {
  21 + var query = client.query("SHOW COLUMNS FROM columnia");
  22 +
  23 + query.on('row', function(row) {
  24 + if (!row.Type) throw new Error('Column order mixed up after '+i+' queries.');
  25 + });
  26 +
  27 + query.on('end', function() {
  28 + finished++;
  29 + if (finished === REPEATS) client.destroy();
  30 + });
  31 + })(i);
  32 +}
  33 +
  34 +process.on('exit', function() {
  35 + assert.equal(finished, REPEATS);
  36 +});
50 test/integration/test-client-query-column-ordering.js
... ... @@ -1,50 +0,0 @@
1   -var common = require('../common');
2   -var assert = require('assert');
3   -var test = common.fastOrSlow.slow();
4   -var mysql = require(common.dir.lib + '/mysql');
5   -var fs = require('fs');
6   -
7   -test.before(function() {
8   - this.client = common.createClient();
9   -});
10   -
11   -test.after(function(done) {
12   - this.client.end(done);
13   -});
14   -
15   -test('Column ordering works properly', {timeout: 15 * 1000}, function(done) {
16   - var REPEATS = 500;
17   -
18   - this.client.query('CREATE DATABASE ' + common.TEST_DB, function(err) {
19   - if (err && err.number != mysql.ERROR_DB_CREATE_EXISTS) {
20   - throw err;
21   - }
22   - });
23   - this.client.query('USE ' + common.TEST_DB);
24   -
25   - this.client.query('DROP TABLE IF EXISTS columnia');
26   - var fixture = fs.readFileSync(common.dir.fixture + '/columnia.sql', 'utf8');
27   - this.client.query(fixture);
28   -
29   - var finished = 0;
30   - var self = this;
31   - for (var i = 0; i < REPEATS; i++) {
32   - (function(i) {
33   - var query = self.client.query("SHOW COLUMNS FROM columnia");
34   -
35   - query.on('row', function(row) {
36   - if (!row.Type) {
37   - throw new Error('Column order mixed up after '+i+' queries.');
38   - }
39   - });
40   -
41   - query.on('end', function() {
42   - finished++;
43   - if (finished === REPEATS) {
44   - done();
45   - }
46   - });
47   - })(i);
48   - }
49   -});
50   -

0 comments on commit baed417

Please sign in to comment.
Something went wrong with that request. Please try again.