mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
Implement volumes, hide networks and volumes tabs for APIs older than v1.21.
This commit is contained in:
parent
8a900254ae
commit
eede27e263
7 changed files with 218 additions and 4 deletions
64
test/unit/app/components/volumesController.spec.js
Normal file
64
test/unit/app/components/volumesController.spec.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
describe('VolumesController', function () {
|
||||
var $scope, $httpBackend, $routeParams;
|
||||
|
||||
beforeEach(module('dockerui'));
|
||||
beforeEach(inject(function (_$httpBackend_, $controller, _$routeParams_) {
|
||||
$scope = {};
|
||||
$httpBackend = _$httpBackend_;
|
||||
$routeParams = _$routeParams_;
|
||||
$controller('VolumesController', {
|
||||
'$scope': $scope,
|
||||
'$routeParams': $routeParams
|
||||
});
|
||||
}));
|
||||
|
||||
it('initializes correctly', function () {
|
||||
expectGetVolumes();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
|
||||
it('issues correct remove calls to the remote API', function () {
|
||||
expectGetVolumes();
|
||||
$httpBackend.flush();
|
||||
$scope.volumes[0].Checked = true;
|
||||
$scope.volumes[2].Checked = true;
|
||||
$httpBackend.expectDELETE('dockerapi/volumes/tardis').respond(200);
|
||||
$httpBackend.expectDELETE('dockerapi/volumes/bar').respond(200);
|
||||
$scope.removeAction();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
it('issues a correct volume creation call to the remote API', function () {
|
||||
expectGetVolumes();
|
||||
var createBody = {
|
||||
"Name": "tardis",
|
||||
"Driver": "local"
|
||||
};
|
||||
$httpBackend.expectPOST('dockerapi/volumes/create', createBody).respond(201);
|
||||
expectGetVolumes();
|
||||
$scope.addVolume(createBody);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
function expectGetVolumes() {
|
||||
$httpBackend.expectGET('dockerapi/volumes').respond({
|
||||
"Volumes": [
|
||||
{
|
||||
"Name": "tardis",
|
||||
"Driver": "local",
|
||||
"Mountpoint": "/var/lib/docker/volumes/tardis"
|
||||
},
|
||||
{
|
||||
"Name": "foo",
|
||||
"Driver": "local",
|
||||
"Mountpoint": "/var/lib/docker/volumes/foo"
|
||||
},
|
||||
{
|
||||
"Name": "bar",
|
||||
"Driver": "local",
|
||||
"Mountpoint": "/var/lib/docker/volumes/bar"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue