deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [3/6] git commit: Tests: Use 'initializers' in all our tests.
Date Mon, 18 Feb 2013 09:54:31 GMT
Tests: Use 'initializers' in all our tests.

This patch will make possible to run our unit-tests without
initializing the Deltacloud.configure classes, because we already
do that in initializers.

For CIMI tests, this will make sure the database directory exists.


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

Branch: refs/heads/master
Commit: 8a65653af3ea67adf12aa1e6eef70df3df775c35
Parents: e472c9f
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Fri Feb 15 11:20:01 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Feb 18 09:58:03 2013 +0100

----------------------------------------------------------------------
 .../cimi/collections/cloud_entry_point_test.rb     |    2 +-
 server/tests/cimi/db/database_helper_test.rb       |    8 --------
 server/tests/cimi/spec_helper.rb                   |    3 +++
 server/tests/deltacloud/common.rb                  |    4 +++-
 server/tests/deltacloud/rack_test.rb               |    4 ++--
 server/tests/test_helper.rb                        |    1 +
 tests/cimi/test_helper.rb                          |    5 ++++-
 7 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/cimi/collections/cloud_entry_point_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/cloud_entry_point_test.rb b/server/tests/cimi/collections/cloud_entry_point_test.rb
index eed8721..a7fdd89 100644
--- a/server/tests/cimi/collections/cloud_entry_point_test.rb
+++ b/server/tests/cimi/collections/cloud_entry_point_test.rb
@@ -18,7 +18,7 @@ describe CIMI::Collections::CloudEntryPoint do
   it 'set the CIMI-Version header' do
     get root_url
     headers['CIMI-Specification-Version'].wont_be_nil
-    headers['CIMI-Specification-Version'].must_equal '1.0.0'
+    headers['CIMI-Specification-Version'].must_equal Deltacloud::CIMI_API_VERSION
   end
 
   it 'advertise CIMI collections in XML format' do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/cimi/db/database_helper_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/db/database_helper_test.rb b/server/tests/cimi/db/database_helper_test.rb
index 30772f8..4d5f7fb 100644
--- a/server/tests/cimi/db/database_helper_test.rb
+++ b/server/tests/cimi/db/database_helper_test.rb
@@ -18,18 +18,10 @@ describe Deltacloud::Helpers::Database do
   BaseModel = CIMI::Model::Base
 
   before do
-    ENV['RACK_ENV'] = 'development'
     @db = DatabaseHelper.new
     @prov = Provider::lookup
   end
 
-  it 'report if application is running under test environment' do
-    ENV['RACK_ENV'] = 'test'
-    @db.test_environment?.must_equal true
-    ENV['RACK_ENV'] = 'development'
-    @db.test_environment?.must_equal false
-  end
-
   it 'report if given entity is provided by database' do
     @db.provides?('machine_template').must_equal true
     @db.provides?('machine').must_equal false

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/cimi/spec_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec_helper.rb b/server/tests/cimi/spec_helper.rb
index 647a520..1f6f9ea 100644
--- a/server/tests/cimi/spec_helper.rb
+++ b/server/tests/cimi/spec_helper.rb
@@ -21,7 +21,10 @@ require 'xmlsimple'
 require 'json/pure'
 require 'require_relative' if RUBY_VERSION < '1.9'
 
+ENV['API_FRONTEND'] = 'cimi'
+
 require_relative '../../lib/deltacloud/core_ext.rb'
+require_relative '../../lib/initialize'
 require_relative '../../lib/cimi/models.rb'
 
 DATA_DIR = File::join(File::expand_path(File::dirname(__FILE__)), 'data')

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/deltacloud/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/common.rb b/server/tests/deltacloud/common.rb
index 2b304d6..cded956 100644
--- a/server/tests/deltacloud/common.rb
+++ b/server/tests/deltacloud/common.rb
@@ -1,7 +1,9 @@
 require_relative '../test_helper.rb'
+
+require_relative File.join('..', '..', 'lib', 'initializers', 'mock_initialize')
 require_relative File.join('..', '..', 'lib', 'initializers', 'frontend_initialize')
 
-Deltacloud.require_frontend!(:deltacloud)
+Deltacloud.require_frontend! :deltacloud
 
 def check_json_serialization_for(model, sample_id, optional_attrs=[])
   header 'Accept', 'application/json'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/deltacloud/rack_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/rack_test.rb b/server/tests/deltacloud/rack_test.rb
index f6eb717..92b8150 100644
--- a/server/tests/deltacloud/rack_test.rb
+++ b/server/tests/deltacloud/rack_test.rb
@@ -38,12 +38,12 @@ describe Deltacloud do
 
     it 'should provide the correct version' do
       Deltacloud.config[:deltacloud].version.must_equal Deltacloud::API_VERSION
-      Deltacloud.config[:cimi].version.must_equal Deltacloud::API_VERSION
+      Deltacloud.config[:cimi].version.must_equal Deltacloud::CIMI_API_VERSION
     end
 
     it 'should provide the logger facility' do
       Deltacloud.config[:deltacloud].logger.must_equal Rack::DeltacloudLogger
-      Deltacloud.config[:cimi].logger.must_equal Logger
+      Deltacloud.config[:cimi].logger.must_equal Rack::DeltacloudLogger
     end
 
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 5785a43..ff16de4 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -8,6 +8,7 @@ require 'require_relative' if RUBY_VERSION < '1.9'
 
 require 'singleton'
 
+require_relative '../lib/initializers/mock_initialize'
 require_relative '../lib/deltacloud/api.rb'
 
 ENV['RACK_ENV'] = 'test'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8a65653a/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index 1720dd7..96e94f6 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -18,8 +18,11 @@ require 'rubygems'
 require 'require_relative' if RUBY_VERSION < '1.9'
 require_relative '../helpers/common.rb'
 require 'singleton'
+
+ENV['API_FRONTEND'] = 'cimi'
+
+require_relative '../../server/lib/initialize'
 require_relative "../../server/lib/cimi/models"
-require 'logger'
 
 # Add CIMI specific config stuff
 module CIMI


Mime
View raw message