mirror of
https://github.com/status-im/consul.git
synced 2025-01-23 12:11:05 +00:00
6589cbbd0d
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import { getAlternateServices } from 'consul-ui/components/discovery-chain/utils';
|
|
import { module, test } from 'qunit';
|
|
|
|
module('Unit | Component | discovery-chain/get-alternative-services', function() {
|
|
test('it guesses a different namespace', function(assert) {
|
|
const expected = {
|
|
Type: 'Namespace',
|
|
Targets: ['different-ns', 'different-ns2'],
|
|
};
|
|
const actual = getAlternateServices(
|
|
['service.different-ns.dc', 'service.different-ns2.dc'],
|
|
'service.namespace.dc'
|
|
);
|
|
assert.equal(actual.Type, expected.Type);
|
|
assert.deepEqual(actual.Targets, expected.Targets);
|
|
});
|
|
test('it guesses a different datacenter', function(assert) {
|
|
const expected = {
|
|
Type: 'Datacenter',
|
|
Targets: ['dc1', 'dc2'],
|
|
};
|
|
const actual = getAlternateServices(
|
|
['service.namespace.dc1', 'service.namespace.dc2'],
|
|
'service.namespace.dc'
|
|
);
|
|
assert.equal(actual.Type, expected.Type);
|
|
assert.deepEqual(actual.Targets, expected.Targets);
|
|
});
|
|
test('it guesses a different service', function(assert) {
|
|
const expected = {
|
|
Type: 'Service',
|
|
Targets: ['service-2', 'service-3'],
|
|
};
|
|
const actual = getAlternateServices(
|
|
['service-2.namespace.dc', 'service-3.namespace.dc'],
|
|
'service.namespace.dc'
|
|
);
|
|
assert.equal(actual.Type, expected.Type);
|
|
assert.deepEqual(actual.Targets, expected.Targets);
|
|
});
|
|
test('it guesses a different subset', function(assert) {
|
|
const expected = {
|
|
Type: 'Subset',
|
|
Targets: ['v3', 'v2'],
|
|
};
|
|
const actual = getAlternateServices(
|
|
['v3.service.namespace.dc', 'v2.service.namespace.dc'],
|
|
'v1.service.namespace.dc'
|
|
);
|
|
assert.equal(actual.Type, expected.Type);
|
|
assert.deepEqual(actual.Targets, expected.Targets);
|
|
});
|
|
});
|