From 00ebbd3c887e46fbfbd0938557102584ecb3f4b1 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Wed, 15 Aug 2012 17:24:17 +0100 Subject: [PATCH] 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) --- lib/fog/bin.rb | 4 ++++ tests/helper.rb | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index c583cd3b0..9f08745be 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -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 diff --git a/tests/helper.rb b/tests/helper.rb index 75bff84fb..6e9b26cfd 100644 --- a/tests/helper.rb +++ b/tests/helper.rb @@ -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