A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
960 B

12 years ago
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. common.useTestDb(connection);
  5. var table = 'stream_test';
  6. connection.query([
  7. 'CREATE TEMPORARY TABLE `' + table + '` (',
  8. '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,',
  9. '`title` varchar(255),',
  10. 'PRIMARY KEY (`id`)',
  11. ') ENGINE=InnoDB DEFAULT CHARSET=utf8'
  12. ].join('\n'));
  13. var rowCount = 10;
  14. for (var i = 1; i <= rowCount; i++) {
  15. var row = {
  16. id: i,
  17. title: 'Row #' + i,
  18. };
  19. connection.query('INSERT INTO ' + table + ' SET ?', row);
  20. }
  21. var destroyed = false;
  22. var hadEnd = false;
  23. var query = connection.query('SELECT * FROM ' + table);
  24. query
  25. .on('result', function(row) {
  26. assert.equal(destroyed, false);
  27. destroyed = true;
  28. connection.destroy();
  29. })
  30. .on('end', function() {
  31. hadEnd = true;
  32. });
  33. connection.end();
  34. process.on('exit', function() {
  35. assert.strictEqual(hadEnd, false);
  36. });