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
|
module TestSupport
|
||||||
# Find a suitable image for testing with
|
# Find a suitable image for testing with
|
||||||
# For speed of server building we're using an empty image
|
# 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
|
def self.image_id
|
||||||
return @image_id unless @image_id.nil?
|
return @image_id unless @image_id.nil?
|
||||||
images = Fog::Compute[:brightbox].list_images
|
image = select_testing_image_from_api
|
||||||
raise "No available images!" if images.empty?
|
|
||||||
image = images.select {|img| img.size == 0 }.first
|
|
||||||
image = images.first if image.nil?
|
|
||||||
@image_id = image["id"]
|
@image_id = image["id"]
|
||||||
|
rescue
|
||||||
|
@image_id = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prepare a test server, wait for it to be usable but raise if it fails
|
# Prepare a test server, wait for it to be usable but raise if it fails
|
||||||
|
@ -62,6 +69,13 @@ class Brightbox
|
||||||
server
|
server
|
||||||
end
|
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
|
end
|
||||||
module Formats
|
module Formats
|
||||||
module Struct
|
module Struct
|
||||||
|
|
|
@ -15,7 +15,7 @@ def compute_providers
|
||||||
},
|
},
|
||||||
:brightbox => {
|
:brightbox => {
|
||||||
:server_attributes => {
|
: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
|
:mocked => false
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue