mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 06:49:40 +02:00
Added PortBindings to container start.
This commit is contained in:
parent
77062bec84
commit
76d7e280f9
4 changed files with 128 additions and 4 deletions
|
@ -0,0 +1,63 @@
|
|||
describe('startContainerController', function () {
|
||||
var scope, $location, createController, mockContainer, $httpBackend;
|
||||
|
||||
beforeEach(angular.mock.module('dockerui'));
|
||||
|
||||
beforeEach(inject(function ($rootScope, $controller, _$location_) {
|
||||
$location = _$location_;
|
||||
scope = $rootScope.$new();
|
||||
|
||||
createController = function() {
|
||||
return $controller('StartContainerController', {
|
||||
'$scope': scope
|
||||
});
|
||||
};
|
||||
|
||||
angular.mock.inject(function (_Container_, _$httpBackend_) {
|
||||
mockContainer = _Container_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
});
|
||||
}));
|
||||
|
||||
describe('Starting a container with options', function () {
|
||||
it('should issue a correct create request to the Docker remote API', function() {
|
||||
var controller = createController();
|
||||
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
||||
var expectedBody = {
|
||||
"name": "container-name",
|
||||
"Memory": 0,
|
||||
"MemorySwap": 0,
|
||||
"CpuShares": 1024,
|
||||
"Cmd": null,
|
||||
"VolumesFrom": "",
|
||||
"ExposedPorts":{
|
||||
"9000/tcp": {},
|
||||
},
|
||||
"HostConfig": {
|
||||
"PortBindings":{
|
||||
"9000/tcp": [{
|
||||
"HostPort": "9999",
|
||||
"HostIp": "10.20.10.15",
|
||||
}]
|
||||
},
|
||||
}};
|
||||
$httpBackend.expectPOST('/dockerapi/containers/create?name=container-name', expectedBody).respond({
|
||||
"Id": id,
|
||||
"Warnings": null
|
||||
});
|
||||
$httpBackend.expectPOST('/dockerapi/containers/' + id + '/start?').respond({
|
||||
"Id": id,
|
||||
"Warnings": null
|
||||
});
|
||||
|
||||
scope.config.name = 'container-name';
|
||||
scope.config.portBindings = [{ip: '10.20.10.15', extPort: '9999', intPort: '9000'}]
|
||||
|
||||
//var response = mockContainer.create({});
|
||||
scope.create();
|
||||
|
||||
$httpBackend.flush();
|
||||
//console.log(response);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue