Merge "Fix the error format of glance's createImage"
This commit is contained in:
commit
ff9cfff507
@ -170,8 +170,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
toastService.add('error', gettext('Unable to create the image.'));
|
if (error && error.data) {
|
||||||
throw error;
|
throw error;
|
||||||
|
} else {
|
||||||
|
throw gettext('Unable to create the image.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiService[method]('/api/glance/images/', image)
|
return apiService[method]('/api/glance/images/', image)
|
||||||
|
@ -185,20 +185,31 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('shows error message when arguments are insufficient', function() {
|
it('shows error message when arguments are insufficient', function() {
|
||||||
spyOn(toastService, 'add');
|
|
||||||
|
|
||||||
service.createImage.apply(null, [{name: 1}]);
|
service.createImage.apply(null, [{name: 1}]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
imageQueuedPromise.reject({'data': 'invalid'});
|
imageQueuedPromise.reject({'data': 'invalid'});
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
}catch (exp) {
|
} catch (error) {
|
||||||
expect(exp).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
expect(exp.data).toEqual('invalid');
|
expect(error.data).toEqual('invalid');
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows a generic message when it gets a unexpected error', function() {
|
||||||
|
service.createImage.apply(null, [{name: 1}]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
imageQueuedPromise.reject();
|
||||||
|
$rootScope.$apply();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toBeDefined();
|
||||||
|
expect(error).toEqual('Unable to create the image.');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1});
|
expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1});
|
||||||
expect(toastService.add).toHaveBeenCalledWith('error', "Unable to create the image.");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('external upload of a local file', function() {
|
describe('external upload of a local file', function() {
|
||||||
@ -237,9 +248,9 @@
|
|||||||
try {
|
try {
|
||||||
imageQueuedPromise.reject({'data': 'invalid'});
|
imageQueuedPromise.reject({'data': 'invalid'});
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
}catch (exp) {
|
} catch (error) {
|
||||||
expect(exp).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
expect(exp.data).toEqual('invalid');
|
expect(error.data).toEqual('invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(apiService.put.calls.count()).toBe(1);
|
expect(apiService.put.calls.count()).toBe(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user