test-change-user-fatal-error.js 787 B

12345678910111213141516171819202122232425
  1. // This test verifies that changeUser errors are treated as fatal errors. The
  2. // rationale for that is that a failure to execute a changeUser sequence may
  3. // cause unexpected behavior for queries that were enqueued under the
  4. // assumption of changeUser to succeed.
  5. var common = require('../../common');
  6. var connection = common.createConnection();
  7. var assert = require('assert');
  8. if (common.isTravis()) {
  9. return console.log('skipping - travis mysql does not support this test');
  10. }
  11. var err;
  12. connection.changeUser({user: 'does-not-exist'}, function(_err) {
  13. err = _err;
  14. connection.end();
  15. });
  16. process.on('exit', function() {
  17. if (process.env.NO_GRANT == '1' && err === null) return;
  18. assert.equal(err.code, 'ER_ACCESS_DENIED_ERROR');
  19. assert.equal(err.fatal, true);
  20. });