Skip to content

Commit

Permalink
ui: Ensure blocking query configuration is passed through to findInst…
Browse files Browse the repository at this point in the history
…anceBySlug (#7543)

* ui: Ensure configuration is passed through to findInstanceBySlug

Due to the addition of namespace support, this arguments passed to this
method have been increased. Whilst the nspace support continues ot work
here, the configuration for blocking queries is never passed through.
This results in a 2 second poll rather than a blocking query.

This commit fixes that

* ui: Add a basic test to check the number of arguments passed through
  • Loading branch information
johncowen authored Mar 30, 2020
1 parent 952b60a commit 31b9b90
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui-v2/app/services/repository/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default RepositoryService.extend({
return service;
});
},
findInstanceBySlug: function(id, node, slug, dc, configuration) {
return this.findBySlug(slug, dc, configuration).then(function(item) {
findInstanceBySlug: function(id, node, slug, dc, nspace, configuration) {
return this.findBySlug(slug, dc, nspace, configuration).then(function(item) {
// TODO: Move this to the Serializer
// Loop through all the service instances and pick out the one
// that has the same service id AND node name
Expand Down
28 changes: 28 additions & 0 deletions ui-v2/tests/integration/services/repository/service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@ const id = 'token-name';
const now = new Date().getTime();
const undefinedNspace = 'default';
[undefinedNspace, 'team-1', undefined].forEach(nspace => {
test(`findInstanceBySlug calls findBySlug with the correct arguments when nspace is ${nspace}`, function(assert) {
assert.expect(4);
const id = 'id';
const slug = 'slug';
const node = 'node-name';

const datacenter = 'dc-1';
const conf = {
cursor: 1,
};
const service = this.subject();
service.findBySlug = function(slug, dc, nspace, configuration) {
assert.equal(
arguments.length,
4,
'Expected to be called with the correct number of arguments'
);
assert.equal(dc, datacenter);
assert.deepEqual(configuration, conf);
return Promise.resolve({ Nodes: [] });
};
// This will throw an error as we don't resolve any services that match what was requested
// so a 404 is the correct error response
return service.findInstanceBySlug(id, slug, node, datacenter, nspace, conf).catch(function(e) {
assert.equal(e.errors[0].status, '404');
});
});

test(`findByDatacenter returns the correct data for list endpoint when nspace is ${nspace}`, function(assert) {
get(this.subject(), 'store').serializerFor(NAME).timestamp = function() {
return now;
Expand Down

0 comments on commit 31b9b90

Please sign in to comment.