deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [4/41] git commit: * server/tests/test_helper.rb: simplify defaulting of user/passeword/provider
Date Mon, 11 Mar 2013 21:36:15 GMT
* server/tests/test_helper.rb: simplify defaulting of user/passeword/provider


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/0dd0249c
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/0dd0249c
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/0dd0249c

Branch: refs/heads/master
Commit: 0dd0249cec055dcd7b4f10a3c44d59c1421b2010
Parents: a97aac4
Author: David Lutterkort <lutter@redhat.com>
Authored: Thu Mar 7 13:56:31 2013 -0800
Committer: David Lutterkort <lutter@redhat.com>
Committed: Mon Mar 11 12:17:50 2013 -0700

----------------------------------------------------------------------
 server/tests/test_helper.rb |   39 +++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/0dd0249c/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 61ee26d..b659227 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -72,10 +72,21 @@ module Deltacloud
 
       def initialize
         fname = ENV["CONFIG"] || File::expand_path("~/.deltacloud/config")
+        @hash = Hash.new do |hash, driver|
+          if hash.has_key?(driver.to_s)
+            hash[driver] = hash[driver.to_s]
+          else
+            hash[driver] = {
+              "user" => "fakeuser",
+              "password" => "fakepassword",
+              "provider" => "fakeprovider"
+            }
+          end
+        end
         begin
-          @hash = YAML.load(File::open(fname))
+          @hash.merge!(YAML.load(File::open(fname)))
         rescue Errno::ENOENT
-          @hash = {}
+          # Ignore
         end
       end
 
@@ -92,26 +103,16 @@ module Deltacloud
       #   provider: compute
       def credentials(driver)
         driver = driver.to_s
-        if @hash.has_key?(driver)
-          user = @hash[driver]["user"]
-          password = @hash[driver]["password"]
-        else
-          user = "fakeuser"
-          password = "fakepassword"
-        end
+        user = @hash[driver]["user"]
+        password = @hash[driver]["password"]
         { :user => user, :password => password }
       end
 
-      def driver(driver, provider = nil)
-        if @hash.has_key?(driver.to_s)
-          user = @hash[driver.to_s]["user"]
-          password = @hash[driver.to_s]["password"]
-          provider = @hash[driver.to_s]["provider"] unless provider
-          params = {:user => user, :password => password, :provider => provider}
-        else
-          provider = "fakeprovider" unless provider
-          params = { :user => "fakeuser", :password => "fakepassword", :provider =>
provider }
-        end
+      def driver(driver)
+        user = @hash[driver.to_s]["user"]
+        password = @hash[driver.to_s]["password"]
+        provider = @hash[driver.to_s]["provider"]
+        params = {:user => user, :password => password, :provider => provider}
         Deltacloud::new(driver, params)
       end
 


Mime
View raw message