Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Coordinates don't require a nspace, so don't expect one in the repo #7378

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ui-v2/app/services/repository/coordinate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
Expand Down
15 changes: 15 additions & 0 deletions ui-v2/tests/integration/services/repository/coordinate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

@kaxcode kaxcode Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration is not set here so it equals {}. How does it equal cursor: 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember we are completely replacing the findAllByDatacenter method here. findByNode calls our fake findAllByDatacenter with the dc and configuration arguments, which it gets from the original call to findAllbyNode('node-name', datacenter, conf), conf being {cursor: 1}, so eventually configuration === {cursor: 1}

Previously we were expecting and passing through an extra nspace argument, which was actually the configuration object, which was the root of the bug.

return Promise.resolve([]);
};
return service.findAllByNode('node-name', datacenter, conf);
});