deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [3/31] git commit: * deltacloud/buckets_test.rb: move bucket/blob creation inside describe
Date Wed, 25 Jul 2012 13:56:38 GMT
* deltacloud/buckets_test.rb: move bucket/blob creation inside describe


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

Branch: refs/heads/master
Commit: be28387afafa32261cd55fc7bd2e37831f8817e8
Parents: b038803
Author: David Lutterkort <lutter@redhat.com>
Authored: Mon Jul 23 17:25:46 2012 -0700
Committer: marios <marios@redhat.com>
Committed: Tue Jul 24 12:03:10 2012 +0300

----------------------------------------------------------------------
 tests/deltacloud/buckets_test.rb |   54 +++++++++++++++-----------------
 1 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/be28387a/tests/deltacloud/buckets_test.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/buckets_test.rb b/tests/deltacloud/buckets_test.rb
index e4ee12e..1601546 100644
--- a/tests/deltacloud/buckets_test.rb
+++ b/tests/deltacloud/buckets_test.rb
@@ -21,44 +21,40 @@ require "deltacloud/test_setup.rb"
 require 'ruby-debug'
 BUCKETS = "/buckets"
 
-def create_a_bucket_and_blob
-  bucket_name = random_name
-  blob_name = random_name
-  res = post(BUCKETS, :name=>bucket_name)
-  unless res.code == 201
-    raise Exception.new("Failed to create bucket #{bucket_name}")
-  end
-
-  res = RestClient.put "#{api.url}/buckets/#{bucket_name}/#{blob_name}",
-    "This is the test blob content",
-    {:Authorization=>api.basic_auth,
-     :content_type=>"text/plain",
-     "X-Deltacloud-Blobmeta-Version"=>"1.0",
-     "X-Deltacloud-Blobmeta-Author"=>"herpyderp"}
-  unless res.code == 200
-    raise Exception.new("Failed to create blob #{blob_name}")
-  end
-  return [ bucket_name, blob_name ]
-end
-
-#make sure we have at least one bucket and blob to test
-created_bucket_and_blob = create_a_bucket_and_blob
-
 describe 'Deltacloud API buckets collection' do
   include Deltacloud::Test::Methods
 
   need_collection :buckets
 
+  #make sure we have at least one bucket and blob to test
+  begin
+    @my_bucket = random_name
+    @my_blob = random_name
+    res = post(BUCKETS, :name=>@my_bucket)
+    unless res.code == 201
+      raise Exception.new("Failed to create bucket #{@my_bucket}")
+    end
+
+    res = RestClient.put "#{api.url}/buckets/#{@my_bucket}/#{@my_blob}",
+    "This is the test blob content",
+    {:Authorization=>api.basic_auth,
+      :content_type=>"text/plain",
+      "X-Deltacloud-Blobmeta-Version"=>"1.0",
+      "X-Deltacloud-Blobmeta-Author"=>"herpyderp"}
+    unless res.code == 200
+      raise Exception.new("Failed to create blob #{@my_blob}")
+    end
+  end
+
+  # delete the bucket/blob we created for the tests
   MiniTest::Unit.after_tests {
-    bucket, blob = created_bucket_and_blob
-    # delete the bucket/blob we created for the tests
-    res = delete("/buckets/#{bucket}/#{blob}")
+    res = delete("/buckets/#{@my_bucket}/#{@my_blob}")
     unless res.code == 204
-      raise Exception.new("Failed to delete blob #{blob}")
+      raise Exception.new("Failed to delete blob #{@my_blob}")
     end
-    res = delete("/buckets/#{bucket}")
+    res = delete("/buckets/#{@my_bucket}")
     unless res.code == 204
-      raise Exception.new("Failed to delete bucket #{bucket}")
+      raise Exception.new("Failed to delete bucket #{@my_bucket}")
     end
   }
 


Mime
View raw message