mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 05:23:04 +00:00
ui: Coordinates don't require a nspace, so don't expect one in the repo (#7378)
* ui: Coordinates don't require a nspace, so don't expect one in the repo * Add a test to prove the correct number of arguments are being passed
This commit is contained in:
parent
468e82dcf9
commit
6074a1b4c8
@ -10,8 +10,19 @@ export default RepositoryService.extend({
|
|||||||
getModelName: function() {
|
getModelName: function() {
|
||||||
return modelName;
|
return modelName;
|
||||||
},
|
},
|
||||||
findAllByNode: function(node, dc, nspace, configuration) {
|
// Coordinates don't need nspaces so we have a custom method here
|
||||||
return this.findAllByDatacenter(dc, nspace, configuration).then(function(coordinates) {
|
// 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 = {};
|
let results = {};
|
||||||
if (get(coordinates, 'length') > 1) {
|
if (get(coordinates, 'length') > 1) {
|
||||||
results = tomography(node, coordinates.map(item => get(item, 'data')));
|
results = tomography(node, coordinates.map(item => get(item, 'data')));
|
||||||
|
@ -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);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user