2020-10-05 17:07:35 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
import getNspaceRunner from 'consul-ui/tests/helpers/get-nspace-runner';
|
|
|
|
|
|
|
|
const nspaceRunner = getNspaceRunner('topology');
|
|
|
|
module('Integration | Adapter | topology', function(hooks) {
|
|
|
|
setupTest(hooks);
|
|
|
|
const dc = 'dc-1';
|
|
|
|
const id = 'slug';
|
2020-10-09 18:39:16 +00:00
|
|
|
const kind = '';
|
2020-10-05 17:07:35 +00:00
|
|
|
test('requestForQueryRecord returns the correct url/method', function(assert) {
|
|
|
|
const adapter = this.owner.lookup('adapter:topology');
|
|
|
|
const client = this.owner.lookup('service:client/http');
|
2020-10-09 18:39:16 +00:00
|
|
|
const expected = `GET /v1/internal/ui/service-topology/${id}?dc=${dc}&kind=${kind}`;
|
2020-10-05 17:07:35 +00:00
|
|
|
const actual = adapter.requestForQueryRecord(client.requestParams.bind(client), {
|
|
|
|
dc: dc,
|
|
|
|
id: id,
|
2020-10-09 18:39:16 +00:00
|
|
|
kind: kind,
|
2020-10-05 17:07:35 +00:00
|
|
|
});
|
|
|
|
assert.equal(`${actual.method} ${actual.url}`, expected);
|
|
|
|
});
|
|
|
|
test("requestForQueryRecord throws if you don't specify an id", function(assert) {
|
|
|
|
const adapter = this.owner.lookup('adapter:topology');
|
|
|
|
const client = this.owner.lookup('service:client/http');
|
|
|
|
assert.throws(function() {
|
|
|
|
adapter.requestForQueryRecord(client.url, {
|
|
|
|
dc: dc,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
test('requestForQueryRecord returns the correct body', function(assert) {
|
|
|
|
return nspaceRunner(
|
|
|
|
(adapter, serializer, client) => {
|
|
|
|
return adapter.requestForQueryRecord(client.body, {
|
|
|
|
id: id,
|
|
|
|
dc: dc,
|
|
|
|
ns: 'team-1',
|
|
|
|
index: 1,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
index: 1,
|
|
|
|
ns: 'team-1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
index: 1,
|
|
|
|
},
|
|
|
|
this,
|
|
|
|
assert
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|