mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[brightbox|compute] Updates to Test helper for select image
* Extracted Image API lookup * Removed inline rescue
This commit is contained in:
parent
deb2ca830e
commit
977f6e3b8b
2 changed files with 19 additions and 5 deletions
|
@ -42,13 +42,20 @@ class Brightbox
|
|||
module TestSupport
|
||||
# Find a suitable image for testing with
|
||||
# For speed of server building we're using an empty image
|
||||
#
|
||||
# Unless the tester has credentials this will fail so we rescue
|
||||
# any errors and return nil.
|
||||
#
|
||||
# This is used in the shared file +tests/compute/helper.rb+ so unfortunately
|
||||
# makes all tests reliant on hardcoded values and each other
|
||||
#
|
||||
# @return [String,NilClass] the most suitable test image's identifier or nil
|
||||
def self.image_id
|
||||
return @image_id unless @image_id.nil?
|
||||
images = Fog::Compute[:brightbox].list_images
|
||||
raise "No available images!" if images.empty?
|
||||
image = images.select {|img| img.size == 0 }.first
|
||||
image = images.first if image.nil?
|
||||
image = select_testing_image_from_api
|
||||
@image_id = image["id"]
|
||||
rescue
|
||||
@image_id = nil
|
||||
end
|
||||
|
||||
# Prepare a test server, wait for it to be usable but raise if it fails
|
||||
|
@ -62,6 +69,13 @@ class Brightbox
|
|||
server
|
||||
end
|
||||
|
||||
private
|
||||
def self.select_testing_image_from_api
|
||||
images = Fog::Compute[:brightbox].list_images
|
||||
raise "No available images!" if images.empty?
|
||||
images.select {|img| img.size == 0 }.first || images.first
|
||||
end
|
||||
|
||||
end
|
||||
module Formats
|
||||
module Struct
|
||||
|
|
|
@ -15,7 +15,7 @@ def compute_providers
|
|||
},
|
||||
:brightbox => {
|
||||
:server_attributes => {
|
||||
:image_id => (Brightbox::Compute::TestSupport.image_id rescue 'img-wwgbb') # Ubuntu Lucid 10.04 server (i686)
|
||||
:image_id => Brightbox::Compute::TestSupport.image_id
|
||||
},
|
||||
:mocked => false
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue