deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [1/2] git commit: Fix Deltacloud server base tests for supported_collections
Date Mon, 17 Sep 2012 10:12:22 GMT
Updated Branches:
  refs/heads/master 1f0170ccd -> b02971cc7


Fix Deltacloud server base tests for supported_collections


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

Branch: refs/heads/master
Commit: b02971cc7907380bcc2a608ac21650886fd5bd54
Parents: 7019a6b
Author: marios <marios@redhat.com>
Authored: Mon Sep 17 13:10:56 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Mon Sep 17 13:10:56 2012 +0300

----------------------------------------------------------------------
 server/tests/deltacloud/deltacloud_helper_test.rb |    9 -----
 server/tests/drivers/base/base_driver_test.rb     |   30 ++++++++++++++++
 server/tests/drivers/base/common.rb               |   14 +++++++
 3 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b02971cc/server/tests/deltacloud/deltacloud_helper_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/deltacloud_helper_test.rb b/server/tests/deltacloud/deltacloud_helper_test.rb
index b7de3e6..c0d1d23 100644
--- a/server/tests/deltacloud/deltacloud_helper_test.rb
+++ b/server/tests/deltacloud/deltacloud_helper_test.rb
@@ -13,15 +13,6 @@ describe Deltacloud::Helpers::Application do
     @helper = ApplicationHelper.new
   end
 
-  it 'provides list of supported collections for the current driver' do
-    @helper.supported_collections.wont_be_empty
-    @helper.supported_collections.must_include Sinatra::Rabbit::InstancesCollection
-    @helper.supported_collections.wont_include Sinatra::Rabbit::LoadBalancersCollection
-    Thread.current[:driver] = 'ec2'
-    @helper.supported_collections.must_include Sinatra::Rabbit::LoadBalancersCollection
-    Thread.current[:driver] = 'mock'
-  end
-
   it 'provides name for the authentication feature' do
     @helper.auth_feature_name.wont_be_nil
     @helper.auth_feature_name.must_equal 'key'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b02971cc/server/tests/drivers/base/base_driver_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/base/base_driver_test.rb b/server/tests/drivers/base/base_driver_test.rb
index b303717..9e1b9df 100644
--- a/server/tests/drivers/base/base_driver_test.rb
+++ b/server/tests/drivers/base/base_driver_test.rb
@@ -8,6 +8,7 @@ require_relative '../../../lib/deltacloud/drivers/base_driver'
 describe Deltacloud::BaseDriver do
 
   before do
+
     class TestDriver < Deltacloud::BaseDriver
 
       define_hardware_profile('t1.micro') do
@@ -36,8 +37,37 @@ describe Deltacloud::BaseDriver do
       end
 
       def realms(credentials, opts={}); end
+
+      def supported_collections(credentials)
+        collections = super
+        #lets add images/instances just for testing of method override from base
+        collections + [Sinatra::Rabbit::ImagesCollection, Sinatra::Rabbit::InstancesCollection]
+      end
     end
+
     @driver = TestDriver.new
+
+  end
+
+  describe 'supported driver collections' do
+
+    it 'provides list of supported collections' do
+      current_driver = Thread.current[:driver]
+      #change to test driver, mock defined in common.rb
+      Thread.current[:driver] = 'test'
+      credentials = OpenStruct.new(:user => 'unkown', :password => 'wrong')
+      @driver.supported_collections(credentials).wont_be_empty
+      @driver.supported_collections(credentials).must_include Sinatra::Rabbit::InstancesCollection
+      #check override of supported_collections, we added Images above
+      @driver.supported_collections(credentials).must_include Sinatra::Rabbit::ImagesCollection
+      @driver.supported_collections(credentials).wont_include Sinatra::Rabbit::KeysCollection
+      #switch driver, check supported_collections
+      Thread.current[:driver] = 'mock'
+      @driver.supported_collections(credentials).must_include Sinatra::Rabbit::KeysCollection
+      #restore driver to not impact other tests
+      Thread.current[:driver] = current_driver
+    end
+
   end
 
   describe 'when creating a new driver' do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b02971cc/server/tests/drivers/base/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/base/common.rb b/server/tests/drivers/base/common.rb
index 46bc7db..163a715 100644
--- a/server/tests/drivers/base/common.rb
+++ b/server/tests/drivers/base/common.rb
@@ -1 +1,15 @@
 require_relative '../../test_helper'
+
+require_relative File.join('..', '..', '..', 'lib', 'deltacloud_rack.rb')
+
+# Setup Deltacloud::API Sinatra instance
+
+Deltacloud::configure do |server|
+  server.root_url '/api'
+  server.version Deltacloud::API_VERSION
+  server.klass 'Deltacloud::API'
+  server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
+  server.default_driver :mock
+end
+
+Deltacloud.require_frontend!


Mime
View raw message