On 24/01/13 14:16, Koper, Dies wrote: > Hi Marios, > > Reviewed and tested to work. ACK with nit: > >> + def collection_supported(name) >> + return true if api.collections.include?(name.to_sym) >> + false >> + end > > Why not just: > > + def collection_supported(name) > + api.collections.include?(name.to_sym) > + end >
thanks will change before push :) > Cheers, > Dies Koper > > >> -----Original Message----- >> From: [email protected] [mailto:[email protected]] >> Sent: Thursday, 24 January 2013 10:15 PM >> To: [email protected] >> Subject: [PATCH] Black box tests - check if collection supported > before >> creating test resource >> >> From: marios <[email protected]> >> >> >> Signed-off-by: marios <[email protected]> >> --- >> 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 >> > >
