Add test case: extend non-exist volume

This patch add test case: volume cannot be extended when the volume
does not exist. For example: when we execute extend CLI, mistype
volume-id accidentally, program will detect that the volume does
not exist and command line will report "ERROR: No volume with a
name or ID of ...".

Change-Id: Iabd1cf8f149a1a63dc8b43744fde52419ca6008e
This commit is contained in:
caixiaoyu 2018-11-28 20:00:28 +08:00
parent da34b35579
commit dd686d0544
1 changed files with 13 additions and 0 deletions

View File

@ -1087,6 +1087,19 @@ class VolumeImageActionsTest(test.TestCase):
mock_extend.assert_called_with(req.environ['cinder.context'],
vol, 2, attached=False)
def test_extend_volume_no_exist(self):
vol_id = fake.WILL_NOT_BE_FOUND_ID
body = {'os-extend': {'new_size': 5}}
req = fakes.HTTPRequest.blank('/v2/%s/volumes/%s/action' %
(fake.PROJECT_ID, vol_id))
self.assertRaises(exception.VolumeNotFound,
self.controller._extend,
req,
vol_id,
body=body)
def test_copy_volume_to_image_notimagename(self):
id = fake.VOLUME2_ID
vol = {"container_format": 'bare',