deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] Black box tests - check if collection supported before creating test resource
Date Thu, 24 Jan 2013 11:14:30 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@redhat.com>
---
 tests/deltacloud/buckets_test.rb   | 2 +-
 tests/deltacloud/instances_test.rb | 2 +-
 tests/deltacloud/test_setup.rb     | 7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/deltacloud/buckets_test.rb b/tests/deltacloud/buckets_test.rb
index 38fc120..c9ac7f5 100644
--- a/tests/deltacloud/buckets_test.rb
+++ b/tests/deltacloud/buckets_test.rb
@@ -50,7 +50,7 @@ describe 'Deltacloud API buckets collection' do
     unless res.code == 200
       raise Exception.new("Failed to create blob #{@@my_blob}")
     end
-  end
+  end if collection_supported :buckets
 
   # delete the bucket/blob we created for the tests
   MiniTest::Unit.after_tests {
diff --git a/tests/deltacloud/instances_test.rb b/tests/deltacloud/instances_test.rb
index d6a916c..73b5ed2 100644
--- a/tests/deltacloud/instances_test.rb
+++ b/tests/deltacloud/instances_test.rb
@@ -33,7 +33,7 @@ describe 'Deltacloud API instances collection' do
     end
     @@my_instance_id = (res.xml/'instance')[0][:id]
     @@created_resources[:instances] << @@my_instance_id
-  end
+  end if collection_supported :instances
 
   #stop/destroy the resources we created for the tests
   MiniTest::Unit.after_tests {
diff --git a/tests/deltacloud/test_setup.rb b/tests/deltacloud/test_setup.rb
index c75b046..b28e456 100644
--- a/tests/deltacloud/test_setup.rb
+++ b/tests/deltacloud/test_setup.rb
@@ -237,6 +237,13 @@ module Deltacloud::Test::Methods
       end
     end
 
+    #convenience method for checking if collection :foo is supported:
+    def collection_supported(name)
+      return true if api.collections.include?(name.to_sym)
+      false
+    end
+
+
     # Only run tests if collection +collection+ supports feature +name+ in
     # the current driver. Use inside a 'describe' block. Tests that are not
     # run because of a missing collection are marked as skipped
-- 
1.7.11.7


Mime
View raw message