Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gce): normalize server group load balancers (#3415)
- Loading branch information
1 parent
74ad6eb
commit f9cd763
Showing
5 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 25 additions & 6 deletions
31
app/scripts/modules/google/serverGroup/serverGroup.transformer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/scripts/modules/google/serverGroup/serverGroup.transformer.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
describe('gceServerGroupTransformer', () => { | ||
let transformer, $q, $scope; | ||
beforeEach( | ||
window.module( | ||
require('./serverGroup.transformer.js') | ||
) | ||
); | ||
|
||
beforeEach(() => { | ||
window.inject((_$q_, $rootScope, _gceServerGroupTransformer_) => { | ||
$q = _$q_; | ||
$scope = $rootScope.$new(); | ||
transformer = _gceServerGroupTransformer_; | ||
}); | ||
}); | ||
|
||
describe('normalize server group load balancers', () => { | ||
let app; | ||
beforeEach(() => { | ||
app = { | ||
getDataSource: () => { | ||
return { | ||
ready: () => $q.resolve(), | ||
data: [ | ||
{name: 'network-load-balancer'}, | ||
{name: 'internal-load-balancer'}, | ||
{name: 'url-map-name', | ||
listeners: [{name: 'http-load-balancer-listener'}, {name: 'https-load-balancer-listener'}]} | ||
] | ||
}; | ||
} | ||
}; | ||
}); | ||
|
||
it('should map listener names to url map names', function () { | ||
let serverGroup = { | ||
loadBalancers: [ | ||
'network-load-balancer', | ||
'internal-load-balancer', | ||
'http-load-balancer-listener', | ||
'https-load-balancer-listener' | ||
] | ||
}; | ||
|
||
let normalizedServerGroup; | ||
transformer.normalizeServerGroup(serverGroup, app) | ||
.then(normalized => normalizedServerGroup = normalized); | ||
$scope.$digest(); | ||
expect(normalizedServerGroup.loadBalancers.length).toBe(3); | ||
expect(normalizedServerGroup.loadBalancers.includes('url-map-name')).toEqual(true); | ||
expect(normalizedServerGroup.loadBalancers.includes('network-load-balancer')).toEqual(true); | ||
expect(normalizedServerGroup.loadBalancers.includes('internal-load-balancer')).toEqual(true); | ||
}); | ||
}); | ||
}); |