mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 14:24:39 +00:00
12811c0844
* Add some tests to check the correct GET API endpoints are called * Refactor adapters 1. Add integration tests for `urlFor...` and majority `handleResponse` methods 2. Refactor out `handleResponse` a little more into single/batch/boolean methods 3. Move setting of the `Datacenter` property into the `handleResponse` method, basically the same place that the uid is being set using the dc parsed form the URL 4. Add some Errors for if you don't pass ids to certain `urlFor` methods
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
import makeAttrable from 'consul-ui/utils/makeAttrable';
|
|
module('Integration | Adapter | acl | url', function(hooks) {
|
|
setupTest(hooks);
|
|
const dc = 'dc-1';
|
|
const id = 'token-name';
|
|
test('urlForQuery returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/list?dc=${dc}`;
|
|
const actual = adapter.urlForQuery({
|
|
dc: dc,
|
|
});
|
|
assert.equal(actual, expected);
|
|
});
|
|
test('urlForQueryRecord returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/info/${id}?dc=${dc}`;
|
|
const actual = adapter.urlForQueryRecord({
|
|
dc: dc,
|
|
id: id,
|
|
});
|
|
assert.equal(actual, expected);
|
|
});
|
|
test("urlForQueryRecord throws if you don't specify an id", function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
assert.throws(function() {
|
|
adapter.urlForQueryRecord({
|
|
dc: dc,
|
|
});
|
|
});
|
|
});
|
|
test('urlForCreateRecord returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/create?dc=${dc}`;
|
|
const actual = adapter.urlForCreateRecord(
|
|
'acl',
|
|
makeAttrable({
|
|
Datacenter: dc,
|
|
ID: id,
|
|
})
|
|
);
|
|
assert.equal(actual, expected);
|
|
});
|
|
test('urlForUpdateRecord returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/update?dc=${dc}`;
|
|
const actual = adapter.urlForUpdateRecord(
|
|
id,
|
|
'acl',
|
|
makeAttrable({
|
|
Datacenter: dc,
|
|
ID: id,
|
|
})
|
|
);
|
|
assert.equal(actual, expected);
|
|
});
|
|
test('urlForDeleteRecord returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/destroy/${id}?dc=${dc}`;
|
|
const actual = adapter.urlForDeleteRecord(
|
|
id,
|
|
'acl',
|
|
makeAttrable({
|
|
Datacenter: dc,
|
|
ID: id,
|
|
})
|
|
);
|
|
assert.equal(actual, expected);
|
|
});
|
|
test('urlForCloneRecord returns the correct url', function(assert) {
|
|
const adapter = this.owner.lookup('adapter:acl');
|
|
const expected = `/v1/acl/clone/${id}?dc=${dc}`;
|
|
const actual = adapter.urlForCloneRecord(
|
|
'acl',
|
|
makeAttrable({
|
|
Datacenter: dc,
|
|
ID: id,
|
|
})
|
|
);
|
|
assert.equal(actual, expected);
|
|
});
|
|
});
|