* @param {Object} options * @returns {LoadBalancingPolicy}
(options)
| 560 | * @returns {LoadBalancingPolicy} |
| 561 | */ |
| 562 | function createDummyPolicy(options) { |
| 563 | const childPolicy = new LoadBalancingPolicy(); |
| 564 | childPolicy.initCalled = 0; |
| 565 | childPolicy.newQueryPlanCalled = 0; |
| 566 | childPolicy.init = function (c, hs, cb) { |
| 567 | childPolicy.initCalled++; |
| 568 | cb(); |
| 569 | }; |
| 570 | childPolicy.getDistance = function (h) { |
| 571 | if (h.address.lastIndexOf('_remote') > 0) { |
| 572 | return types.distance.remote; |
| 573 | } |
| 574 | return types.distance.local; |
| 575 | }; |
| 576 | childPolicy.newQueryPlan = function (k, o, cb) { |
| 577 | childPolicy.newQueryPlanCalled++; |
| 578 | |
| 579 | const hosts = [ new Host('repl2_local', 2, options), new Host('child1', 2, options), new Host('child2', 2, options) ]; |
| 580 | cb(null, utils.arrayIterator(hosts)); |
| 581 | }; |
| 582 | return childPolicy; |
| 583 | } |
| 584 | /** |
| 585 | * Creates a dummy host map containing the key as key and value |
| 586 | * @param {Array} hosts |
no test coverage detected