mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #469 from dylanegan/mock_image_states
[compute|aws] Allow image mocks to support state (except failed).
This commit is contained in:
commit
40aaf4397a
4 changed files with 22 additions and 2 deletions
|
@ -37,6 +37,10 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == 'available'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -109,6 +109,16 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
image_set = image_set.map do |image|
|
||||
case image['imageState']
|
||||
when 'pending'
|
||||
if Time.now - image['registered'] >= Fog::Mock.delay
|
||||
image['imageState'] = 'available'
|
||||
end
|
||||
end
|
||||
image.reject { |key, value| ['registered'].include?(key) }
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
|
|
|
@ -69,7 +69,7 @@ module Fog
|
|||
image = {
|
||||
'imageId' => Fog::AWS::Mock.image_id,
|
||||
'imageLocation' => '',
|
||||
'imageState' => 'available',
|
||||
'imageState' => 'pending',
|
||||
'imageOwnerId' => self.data[:owner_id],
|
||||
'isPublic' => false,
|
||||
'productCodes' => [],
|
||||
|
@ -87,7 +87,8 @@ module Fog
|
|||
'blockDeviceMapping' => [],
|
||||
'virtualizationType' => 'paravirtual',
|
||||
'tagSet' => {},
|
||||
'hypervisor' => 'xen'
|
||||
'hypervisor' => 'xen',
|
||||
'registered' => Time.now
|
||||
}
|
||||
|
||||
if location[/^\/dev\/sd[a-p]\d{0,2}$/]
|
||||
|
|
|
@ -44,10 +44,15 @@ Shindo.tests('Fog::Compute[:aws] | image requests', ['aws']) do
|
|||
end
|
||||
|
||||
@image_id = @image['imageId']
|
||||
sleep 1
|
||||
|
||||
tests("#describe_images('Owner' => 'self')").formats(@describe_images_format) do
|
||||
Fog::Compute[:aws].describe_images('Owner' => 'self').body
|
||||
end
|
||||
|
||||
tests("#describe_images('state' => 'available')").formats(@describe_images_format) do
|
||||
Fog::Compute[:aws].describe_images('state' => 'available').body
|
||||
end
|
||||
end
|
||||
|
||||
tests("#describe_images('image-id' => '#{@image_id}')").formats(@describe_images_format) do
|
||||
|
|
Loading…
Reference in a new issue