deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 3/4] Encapsulate the test for whether we need a DB in Deltacloud::need_database?
Date Wed, 20 Feb 2013 04:54:27 GMT
From: David Lutterkort <lutter@redhat.com>

---
 server/lib/deltacloud_rack.rb | 4 ++++
 server/lib/initialize.rb      | 5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud_rack.rb b/server/lib/deltacloud_rack.rb
index 32ff4e8..dbf51fc 100644
--- a/server/lib/deltacloud_rack.rb
+++ b/server/lib/deltacloud_rack.rb
@@ -75,6 +75,10 @@ module Deltacloud
     ENV['API_FRONTEND'].split(',')
   end
 
+  def self.need_database?
+    frontends.include?('cimi') || ENV['RACK_ENV'] == 'test'
+  end
+
   require 'sinatra/base'
   require_relative './deltacloud/helpers/deltacloud_helper'
   require_relative './sinatra/rack_accept'
diff --git a/server/lib/initialize.rb b/server/lib/initialize.rb
index ec38c0a..c82bd8d 100644
--- a/server/lib/initialize.rb
+++ b/server/lib/initialize.rb
@@ -23,5 +23,6 @@ require_relative './initializers/mock_initialize'
 # Configure available frontends
 require_relative './initializers/frontend_initialize'
 
-# If CIMI is enabled, then initialize database stuff
-require_relative './initializers/database_initialize' if frontends.include? 'cimi'
+if Deltacloud::need_database?
+  require_relative './initializers/database_initialize'
+end
-- 
1.8.1.2


Mime
View raw message