mirror of https://github.com/status-im/consul.git
ui: Test coverage developer experience (#7275)
* ui: Add getSplitters unit test and additional getResolvers test * Make ordering of makefile target consistent
This commit is contained in:
parent
771973a713
commit
e9ed49d9aa
|
@ -73,8 +73,8 @@ specify-coverage:
|
|||
test-coverage: deps specify-coverage
|
||||
yarn run test:coverage
|
||||
|
||||
test-view-coverage: deps specify-coverage
|
||||
yarn run test:view:coverage
|
||||
test-coverage-view: deps specify-coverage
|
||||
yarn run test:coverage:view
|
||||
|
||||
test-parallel: deps
|
||||
yarn run test:parallel
|
||||
|
|
|
@ -39,7 +39,7 @@ export const getSplitters = function(nodes) {
|
|||
// Splitters need IDs adding so we can find them in the DOM later
|
||||
// splitters have a service.nspace as a name
|
||||
// do the reverse dance to ensure we don't mess up any
|
||||
// serivice names with dots in them
|
||||
// service names with dots in them
|
||||
const temp = item.Name.split('.');
|
||||
temp.reverse();
|
||||
temp.shift();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"test:oss:view": "CONSUL_NSPACES_ENABLED=0 ember test --server --test-port=${EMBER_TEST_PORT:-7357}",
|
||||
"test:node": "tape ./node-tests/**/*.js",
|
||||
"test:coverage": "COVERAGE=true ember test --environment test --filter=Unit --test-port=${EMBER_TEST_PORT:-7357}",
|
||||
"test:view:coverage": "COVERAGE=true ember test --server --environment test --filter=Unit --test-port=${EMBER_TEST_PORT:-7357}",
|
||||
"test:coverage:view": "COVERAGE=true ember test --server --environment test --filter=Unit --test-port=${EMBER_TEST_PORT:-7357}",
|
||||
"steps:list": "node ./lib/commands/bin/list.js"
|
||||
},
|
||||
"husky": {
|
||||
|
|
|
@ -105,7 +105,7 @@ module('Unit | Utility | components/discovery-chain/get-resolvers', function() {
|
|||
Type: 'resolver',
|
||||
Name: 'v2.dc-failover.default.dc-1',
|
||||
Resolver: {
|
||||
Target: 'v2.dc-failover.defauilt.dc-1',
|
||||
Target: 'v2.dc-failover.default.dc-1',
|
||||
Failover: {
|
||||
Targets: ['v2.dc-failover.default.dc-5', 'v2.dc-failover.default.dc-6'],
|
||||
},
|
||||
|
@ -166,7 +166,7 @@ module('Unit | Utility | components/discovery-chain/get-resolvers', function() {
|
|||
Type: 'resolver',
|
||||
Name: 'dc-failover.default.dc-1',
|
||||
Resolver: {
|
||||
Target: 'dc-failover.defauilt.dc-1',
|
||||
Target: 'dc-failover.default.dc-1',
|
||||
Failover: {
|
||||
Targets: ['dc-failover.default.dc-5', 'dc-failover.default.dc-6'],
|
||||
},
|
||||
|
@ -196,4 +196,60 @@ module('Unit | Utility | components/discovery-chain/get-resolvers', function() {
|
|||
assert.deepEqual(actual[0], expected);
|
||||
});
|
||||
});
|
||||
test('it finds services with redirects with failovers correctly', function(assert) {
|
||||
return Promise.resolve({
|
||||
Chain: {
|
||||
ServiceName: 'service-name',
|
||||
Namespace: 'default',
|
||||
Datacenter: 'dc-1',
|
||||
Protocol: 'http',
|
||||
StartNode: '',
|
||||
Nodes: {
|
||||
'resolver:dc-failover.default.redirect-dc-1': {
|
||||
Type: 'resolver',
|
||||
Name: 'dc-failover.default.redirect-dc-1',
|
||||
Resolver: {
|
||||
Target: 'dc-failover.default.redirect-dc-1',
|
||||
Failover: {
|
||||
Targets: ['dc-failover.default.redirect-dc-5', 'dc-failover.default.redirect-dc-6'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Targets: {
|
||||
'dc-failover.default.redirect-dc-1': {
|
||||
ID: 'dc-failover.default.redirect-dc-1',
|
||||
Service: 'dc-failover',
|
||||
Namespace: 'default',
|
||||
Datacenter: 'redirect-dc-1',
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then(function({ Chain }) {
|
||||
const actual = getResolvers(dc, nspace, Chain.Targets, Chain.Nodes);
|
||||
// Both the parent and the child should have a Failover property
|
||||
// as in order for a redirect to have failovers it must redirect to a
|
||||
// service that already has failovers
|
||||
const expected = {
|
||||
ID: 'dc-failover.default.dc-1',
|
||||
Name: 'dc-failover',
|
||||
Failover: {
|
||||
Targets: ['redirect-dc-5', 'redirect-dc-6'],
|
||||
Type: 'Datacenter',
|
||||
},
|
||||
Children: [
|
||||
{
|
||||
Failover: {
|
||||
Targets: ['redirect-dc-5', 'redirect-dc-6'],
|
||||
Type: 'Datacenter',
|
||||
},
|
||||
ID: 'dc-failover.default.redirect-dc-1',
|
||||
Name: 'redirect-dc-1',
|
||||
Redirect: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
assert.deepEqual(actual[0], expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
import { getSplitters } from 'consul-ui/utils/components/discovery-chain/index';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Utility | components/discovery-chain/get-splitters', function() {
|
||||
test('it collects and correctly parses splitter Names', function(assert) {
|
||||
const actual = getSplitters({
|
||||
'splitter:splitter-name.default': {
|
||||
Type: 'splitter',
|
||||
Name: 'splitter-name.default',
|
||||
Splits: [
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
'splitter:not-splitter-name.default': {
|
||||
Type: 'not-splitter',
|
||||
Name: 'splitter-name.default',
|
||||
Splits: [
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const expected = {
|
||||
Type: 'splitter',
|
||||
Name: 'splitter-name',
|
||||
ID: 'splitter:splitter-name.default',
|
||||
Splits: [
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
{
|
||||
Weight: 50,
|
||||
NextNode: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
assert.equal(actual.length, 1);
|
||||
assert.deepEqual(actual[0], expected);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue