incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r1063024 - in /incubator/deltacloud/trunk/server: lib/deltacloud/drivers/mock/mock_driver.rb tests/drivers/mock/api_test.rb
Date Mon, 24 Jan 2011 22:20:52 GMT
Author: lutter
Date: Mon Jan 24 22:20:52 2011
New Revision: 1063024

URL: http://svn.apache.org/viewvc?rev=1063024&view=rev
Log:
mock driver: allow switching to storage-only driver

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb
    incubator/deltacloud/trunk/server/tests/drivers/mock/api_test.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb?rev=1063024&r1=1063023&r2=1063024&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb Mon Jan 24
22:20:52 2011
@@ -25,8 +25,15 @@ module Deltacloud
     module Mock
 class MockDriver < Deltacloud::BaseDriver
 
+  # If the provider is set to storage, pretend to be a storage-only
+  # driver
   def supported_collections
-    DEFAULT_COLLECTIONS + [ :buckets, :keys]
+    endpoint = Thread.current[:provider] || ENV['API_PROVIDER']
+    if endpoint == 'storage'
+      [:buckets]
+    else
+      DEFAULT_COLLECTIONS + [:buckets, :keys]
+    end
   end
 
   ( REALMS = [

Modified: incubator/deltacloud/trunk/server/tests/drivers/mock/api_test.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/tests/drivers/mock/api_test.rb?rev=1063024&r1=1063023&r2=1063024&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/tests/drivers/mock/api_test.rb (original)
+++ incubator/deltacloud/trunk/server/tests/drivers/mock/api_test.rb Mon Jan 24 22:20:52 2011
@@ -34,5 +34,19 @@ module DeltacloudUnitTest
       JSON::parse(last_response.body)['api'].class.should == Hash
     end
 
+    def test_it_switches_drivers
+      begin
+        ENV.delete("API_PROVIDER")
+        do_xml_request '/api'
+        (last_xml_response/"api/link[rel = 'instances']").first.should_not == nil
+
+        # Switch to storage-only mock driver
+        ENV["API_PROVIDER"] = "storage"
+        do_xml_request '/api'
+        (last_xml_response/"api/link[rel = 'instances']").first.should == nil
+      ensure
+        ENV.delete("API_PROVIDER")
+      end
+    end
   end
 end



Mime
View raw message