incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/4] Added task for Mock driver fixtures setup/reset inside server directory
Date Wed, 27 Apr 2011 11:07:58 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/Rakefile |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/server/Rakefile b/server/Rakefile
index e6b59b8..33bfe65 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -89,3 +89,42 @@ spec = Gem::Specification.load('deltacloud-core.gemspec')
 Rake::GemPackageTask.new(spec) do |pkg|
   pkg.need_tar = true
 end
+
+namespace :mock do
+  namespace :fixtures do
+    desc "Setup Mock driver fixtures"
+    task 'setup' do
+      if ENV["DELTACLOUD_MOCK_STORAGE"]
+        storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
+      elsif ENV["USER"]
+        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
+      else
+        raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
+      end
+      data = Dir::glob(File::join(File::dirname(__FILE__), "lib", "deltacloud", "drivers",
"mock", "data", "*"))
+      FileUtils::mkdir_p(storage_root, :verbose => true)
+      FileUtils::cp_r(data, storage_root, :verbose => true)
+    end
+
+    desc "Remove Mock driver fixtures"
+    task 'clean' do
+      if ENV["DELTACLOUD_MOCK_STORAGE"]
+        storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
+      elsif ENV["USER"]
+        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
+      else
+        raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
+      end
+      FileUtils::rm_rf(storage_root, :verbose => true)
+    end
+
+    desc "Reset Mock driver fixtures"
+    task 'reset' do
+      Rake::Task["fixtures:clean"].reenable
+      Rake::Task["fixtures:clean"].invoke
+      Rake::Task["fixtures:setup"].reenable
+      Rake::Task["fixtures:setup"].invoke
+    end
+
+  end
+end
-- 
1.7.4.1


Mime
View raw message