test-ConnectionConfig.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. var common = require('../common');
  2. var test = require('utest');
  3. var assert = require('assert');
  4. var Charsets = require(common.lib + '/protocol/constants/charsets');
  5. var ConnectionConfig = require(common.lib + '/ConnectionConfig');
  6. test('ConnectionConfig#Constructor', {
  7. 'takes user,pw,host,port,db from url string': function() {
  8. var url = 'mysql://myuser:mypass@myhost:3333/mydb';
  9. var config = new ConnectionConfig(url);
  10. assert.equal(config.host, 'myhost');
  11. assert.equal(config.port, 3333);
  12. assert.equal(config.user, 'myuser');
  13. assert.equal(config.password, 'mypass');
  14. assert.equal(config.database, 'mydb');
  15. },
  16. 'allows additional options via url query': function() {
  17. var url = 'mysql://myhost/mydb?debug=true&charset=BIG5_CHINESE_CI';
  18. var config = new ConnectionConfig(url);
  19. assert.equal(config.host, 'myhost');
  20. assert.equal(config.port, 3306);
  21. assert.equal(config.database, 'mydb');
  22. assert.equal(config.debug, true);
  23. assert.equal(config.charsetNumber, Charsets.BIG5_CHINESE_CI);
  24. },
  25. });