test-connection-config-flags.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var ConnectionConfig = require('../../../lib/ConnectionConfig');
  2. var ClientConstants = require('../../../lib/protocol/constants/client');
  3. var assert = require('assert');
  4. var testFlags = [{
  5. 'default' : [ '' ],
  6. 'user' : 'LONG_PASSWORD',
  7. 'expected': ClientConstants.CLIENT_LONG_PASSWORD
  8. }, {
  9. 'default' : [ '' ],
  10. 'user' : '-LONG_PASSWORD',
  11. 'expected': 0x0
  12. }, {
  13. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  14. 'user' : '-LONG_PASSWORD',
  15. 'expected': ClientConstants.CLIENT_FOUND_ROWS
  16. }, {
  17. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  18. 'user' : '-FOUND_ROWS',
  19. 'expected': ClientConstants.CLIENT_LONG_PASSWORD
  20. }, {
  21. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  22. 'user' : '-LONG_FLAG',
  23. 'expected': ClientConstants.CLIENT_LONG_PASSWORD |
  24. ClientConstants.CLIENT_FOUND_ROWS
  25. }, {
  26. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  27. 'user' : 'LONG_FLAG',
  28. 'expected': ClientConstants.CLIENT_LONG_PASSWORD |
  29. ClientConstants.CLIENT_FOUND_ROWS |
  30. ClientConstants.CLIENT_LONG_FLAG
  31. }, {
  32. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  33. 'user' : 'UNDEFINED_CONSTANT',
  34. 'expected': ClientConstants.CLIENT_LONG_PASSWORD |
  35. ClientConstants.CLIENT_FOUND_ROWS
  36. }, {
  37. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  38. 'user' : '-UNDEFINED_CONSTANT',
  39. 'expected': ClientConstants.CLIENT_LONG_PASSWORD |
  40. ClientConstants.CLIENT_FOUND_ROWS
  41. }, {
  42. 'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
  43. 'user' : '-UNDEFINED_CONSTANT,, -found_ROWS',
  44. 'expected': ClientConstants.CLIENT_LONG_PASSWORD
  45. }];
  46. for (var i = 0; i < testFlags.length; i++) {
  47. // console.log("expected: %s got: %s", testFlags[i]['expected'],
  48. // ConnectionConfig.mergeFlags(testFlags[i]['default'], testFlags[i]['user']));
  49. assert.strictEqual(testFlags[i]['expected'],
  50. ConnectionConfig.mergeFlags(testFlags[i]['default'], testFlags[i]['user']));
  51. }