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.

33 lines
792 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 procedureName = 'singleSelectProcedure';
  6. var input = 1;
  7. var fieldName = 'param';
  8. var result = undefined;
  9. connection.query([
  10. 'CREATE DEFINER=root@localhost PROCEDURE '+procedureName+'(IN '+fieldName+' INT)',
  11. 'BEGIN',
  12. 'SELECT '+fieldName+';',
  13. 'END'
  14. ].join('\n'));
  15. connection.query('CALL '+procedureName+'(?)', [input], function(err, _result) {
  16. if (err) throw err;
  17. _result.pop(); // drop metadata
  18. result = _result;
  19. });
  20. connection.query('DROP PROCEDURE '+procedureName);
  21. connection.end();
  22. process.on('exit', function() {
  23. var expected = {};
  24. expected[fieldName] = input;
  25. assert.deepEqual(result, [[expected]]);
  26. });