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.

48 lines
1.4 KiB

  1. /*
  2. * node-rdkafka - Node.js wrapper for RdKafka C/C++ library
  3. *
  4. * Copyright (c) 2016 Blizzard Entertainment
  5. *
  6. * This software may be modified and distributed under the terms
  7. * of the MIT license. See the LICENSE.txt file for details.
  8. */
  9. var KafkaConsumer = require('../lib/kafka-consumer');
  10. var t = require('assert');
  11. var client;
  12. var defaultConfig = {
  13. 'client.id': 'kafka-mocha',
  14. 'group.id': 'kafka-mocha-grp',
  15. 'metadata.broker.list': 'localhost:9092'
  16. };
  17. var topicConfig = {};
  18. module.exports = {
  19. 'KafkaConsumer client': {
  20. 'beforeEach': function() {
  21. client = new KafkaConsumer(defaultConfig, topicConfig);
  22. },
  23. 'afterEach': function() {
  24. client = null;
  25. },
  26. 'does not modify config and clones it': function () {
  27. t.deepStrictEqual(defaultConfig, {
  28. 'client.id': 'kafka-mocha',
  29. 'group.id': 'kafka-mocha-grp',
  30. 'metadata.broker.list': 'localhost:9092'
  31. });
  32. t.deepStrictEqual(client.globalConfig, {
  33. 'client.id': 'kafka-mocha',
  34. 'group.id': 'kafka-mocha-grp',
  35. 'metadata.broker.list': 'localhost:9092'
  36. });
  37. t.notEqual(defaultConfig, client.globalConfig);
  38. },
  39. 'does not modify topic config and clones it': function () {
  40. t.deepStrictEqual(topicConfig, {});
  41. t.deepStrictEqual(client.topicConfig, {});
  42. t.notEqual(topicConfig, client.topicConfig);
  43. },
  44. },
  45. };