2018-08-29 09:00:15 +00:00
|
|
|
import { moduleFor, test } from 'ember-qunit';
|
|
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
2019-05-15 13:44:57 +00:00
|
|
|
import { get } from '@ember/object';
|
2018-10-26 16:36:15 +00:00
|
|
|
const NAME = 'service';
|
|
|
|
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
2018-08-29 09:00:15 +00:00
|
|
|
// Specify the other units that are required for this test.
|
2018-10-26 16:36:15 +00:00
|
|
|
integration: true,
|
2018-08-29 09:00:15 +00:00
|
|
|
});
|
|
|
|
const dc = 'dc-1';
|
2019-05-15 13:44:57 +00:00
|
|
|
const now = new Date().getTime();
|
2019-12-17 18:47:37 +00:00
|
|
|
const undefinedNspace = 'default';
|
2021-09-15 18:50:11 +00:00
|
|
|
const undefinedPartition = 'default';
|
|
|
|
const partition = 'default';
|
2019-12-17 18:47:37 +00:00
|
|
|
[undefinedNspace, 'team-1', undefined].forEach(nspace => {
|
2020-05-29 15:07:36 +00:00
|
|
|
test(`findGatewayBySlug returns the correct data for list endpoint when nspace is ${nspace}`, function(assert) {
|
|
|
|
get(this.subject(), 'store').serializerFor(NAME).timestamp = function() {
|
|
|
|
return now;
|
|
|
|
};
|
|
|
|
const gateway = 'gateway';
|
|
|
|
const conf = {
|
|
|
|
cursor: 1,
|
|
|
|
};
|
|
|
|
return repo(
|
|
|
|
'Service',
|
|
|
|
'findGatewayBySlug',
|
|
|
|
this.subject(),
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(
|
|
|
|
`/v1/internal/ui/gateway-services-nodes/${gateway}?dc=${dc}${
|
|
|
|
typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``
|
2021-09-15 18:50:11 +00:00
|
|
|
}${typeof partition !== 'undefined' ? `&partition=${partition}` : ``}`,
|
2020-05-29 15:07:36 +00:00
|
|
|
{
|
|
|
|
CONSUL_SERVICE_COUNT: '100',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
2021-09-15 18:50:11 +00:00
|
|
|
return service.findGatewayBySlug(
|
|
|
|
{
|
|
|
|
gateway,
|
|
|
|
dc,
|
|
|
|
ns: nspace || undefinedNspace,
|
|
|
|
partition: partition || undefinedPartition,
|
|
|
|
},
|
|
|
|
conf
|
|
|
|
);
|
2020-05-29 15:07:36 +00:00
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
2021-01-20 15:36:23 +00:00
|
|
|
const result = expected(function(payload) {
|
|
|
|
return payload.map(item =>
|
|
|
|
Object.assign({}, item, {
|
|
|
|
SyncTime: now,
|
|
|
|
Datacenter: dc,
|
|
|
|
Namespace: item.Namespace || undefinedNspace,
|
2021-09-15 18:50:11 +00:00
|
|
|
Partition: item.Partition || undefinedPartition,
|
|
|
|
uid: `["${item.Partition || undefinedPartition}","${item.Namespace ||
|
|
|
|
undefinedNspace}","${dc}","${item.Name}"]`,
|
2021-01-20 15:36:23 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
assert.equal(actual[0].SyncTime, result[0].SyncTime);
|
|
|
|
assert.equal(actual[0].Datacenter, result[0].Datacenter);
|
|
|
|
assert.equal(actual[0].Namespace, result[0].Namespace);
|
2021-09-15 18:50:11 +00:00
|
|
|
assert.equal(actual[0].Partition, result[0].Partition);
|
2021-01-20 15:36:23 +00:00
|
|
|
assert.equal(actual[0].uid, result[0].uid);
|
2020-05-29 15:07:36 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2018-08-29 09:00:15 +00:00
|
|
|
});
|