Reduce maintenance of tests by using a dynamic list of providers

Added registered_providers which returns the providers Fog knows about
Remove the providers for local VMs (not lacking credentials but installs)
This commit is contained in:
Paul Thornthwaite 2012-08-15 17:24:17 +01:00
parent 6ee6aaad9a
commit 00ebbd3c88
2 changed files with 14 additions and 3 deletions

View File

@ -7,6 +7,10 @@ module Fog
@available_providers ||= Fog.providers.values.select {|provider| Kernel.const_get(provider).available?}.sort
end
def registered_providers
@registered_providers ||= Fog.providers.values.sort
end
end
class Bin

View File

@ -1,5 +1,5 @@
require 'fog'
require 'fog/bin' # for available_providers
require 'fog/bin' # for available_providers and registered_providers
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
@ -12,9 +12,16 @@ def array_differences(array_a, array_b)
end
# check to see which credentials are available and add others to the skipped tags list
all_providers = ['aws', 'bare_metal_cloud', 'bluebox', 'brightbox', 'clodo', 'cloudstack', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'hp', 'ibm', 'joyent', 'linode', 'local', 'ninefold', 'openstack', 'ovirt', 'rackspace', 'stormondemand', 'vcloud', 'voxel', 'vsphere', 'xenserver', 'zerigo']
all_providers = Fog.registered_providers.map {|provider| provider.downcase}
# Manually remove these providers since they are local applications, not lacking credentials
all_providers = all_providers - ["libvirt", "virtualbox", "vmfusion"]
available_providers = Fog.available_providers.map {|provider| provider.downcase}
for provider in (all_providers - available_providers)
unavailable_providers = all_providers - available_providers
for provider in unavailable_providers
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")
Thread.current[:tags] << ('-' << provider)
end