Skip to content

Commit

Permalink
mock driver: allow switching to storage-only driver
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/deltacloud/trunk@1063024 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
David Lutterkort committed Jan 24, 2011
1 parent 7c97d6f commit 108ebfd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/lib/deltacloud/drivers/mock/mock_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ module Drivers
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 = [
Expand Down
14 changes: 14 additions & 0 deletions server/tests/drivers/mock/api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,19 @@ def test_it_responses_to_json
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

0 comments on commit 108ebfd

Please sign in to comment.