From 36c89e0465e29c28077e630d84f430f1d770a9d3 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 3 Mar 2020 16:57:00 +0000 Subject: [PATCH 1/2] ui: Coordinates don't require a nspace, so don't expect one in the repo --- ui-v2/app/services/repository/coordinate.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui-v2/app/services/repository/coordinate.js b/ui-v2/app/services/repository/coordinate.js index f20d701850a9..86f07e259601 100644 --- a/ui-v2/app/services/repository/coordinate.js +++ b/ui-v2/app/services/repository/coordinate.js @@ -10,8 +10,19 @@ export default RepositoryService.extend({ getModelName: function() { return modelName; }, - findAllByNode: function(node, dc, nspace, configuration) { - return this.findAllByDatacenter(dc, nspace, configuration).then(function(coordinates) { + // Coordinates don't need nspaces so we have a custom method here + // that doesn't accept nspaces + findAllByDatacenter: function(dc, configuration = {}) { + const query = { + dc: dc, + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } + return this.store.query(this.getModelName(), query); + }, + findAllByNode: function(node, dc, configuration) { + return this.findAllByDatacenter(dc, configuration).then(function(coordinates) { let results = {}; if (get(coordinates, 'length') > 1) { results = tomography(node, coordinates.map(item => get(item, 'data'))); From 7e631f48c97682e03215cf7166b7d5c8b0cdec8d Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 3 Mar 2020 17:28:58 +0000 Subject: [PATCH 2/2] Add a test to prove the correct number of arguments are being passed --- .../services/repository/coordinate-test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui-v2/tests/integration/services/repository/coordinate-test.js b/ui-v2/tests/integration/services/repository/coordinate-test.js index dcbba7398817..cdb390b67b51 100644 --- a/ui-v2/tests/integration/services/repository/coordinate-test.js +++ b/ui-v2/tests/integration/services/repository/coordinate-test.js @@ -44,3 +44,18 @@ test('findAllByDatacenter returns the correct data for list endpoint', function( } ); }); +test('findAllByNode calls findAllByDatacenter with the correct arguments', function(assert) { + assert.expect(3); + const datacenter = 'dc-1'; + const conf = { + cursor: 1, + }; + const service = this.subject(); + service.findAllByDatacenter = function(dc, configuration) { + assert.equal(arguments.length, 2, 'Expected to be called with the correct number of arguments'); + assert.equal(dc, datacenter); + assert.deepEqual(configuration, conf); + return Promise.resolve([]); + }; + return service.findAllByNode('node-name', datacenter, conf); +});