deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [25/31] git commit: Move create/delete bucket and blob helpers into buckets_test
Date Wed, 25 Jul 2012 13:56:38 GMT
Move create/delete bucket and blob helpers into buckets_test

We might actually want some other module for these kinds of setups eventually


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

Branch: refs/heads/master
Commit: f8a8d3a3f59390fa67807dd980ad43ce7e6cf614
Parents: 6db26b4
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Jul 20 17:35:52 2012 -0700
Committer: marios <marios@redhat.com>
Committed: Tue Jul 24 12:01:36 2012 +0300

----------------------------------------------------------------------
 tests/deltacloud/buckets_test.rb |   33 ++++++++++++++++++++++++++++++---
 tests/deltacloud/test_setup.rb   |   23 -----------------------
 2 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f8a8d3a3/tests/deltacloud/buckets_test.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/buckets_test.rb b/tests/deltacloud/buckets_test.rb
index 8bae4fd..6b4b743 100644
--- a/tests/deltacloud/buckets_test.rb
+++ b/tests/deltacloud/buckets_test.rb
@@ -21,6 +21,26 @@ 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=>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
 bucket, blob = create_a_bucket_and_blob
 
@@ -28,9 +48,16 @@ features_hash = discover_features
 
 describe 'Deltacloud API buckets collection' do
 
-  MiniTest::Unit.after_tests{
-    #finally delete the bucket/blob we created for the tests:
-    delete_bucket_and_blob(bucket, blob)
+  MiniTest::Unit.after_tests {
+    # delete the bucket/blob we created for the tests
+    res = delete("/buckets/#{bucket}/#{blob}")
+    unless res.code == 204
+      raise Exception.new("Failed to delete blob #{blob}")
+    end
+    res = delete("/buckets/#{bucket}")
+    unless res.code == 204
+      raise Exception.new("Failed to delete bucket #{bucket}")
+    end
   }
 
   it 'must advertise the buckets collection in API entrypoint' do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f8a8d3a3/tests/deltacloud/test_setup.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/test_setup.rb b/tests/deltacloud/test_setup.rb
index ce1975c..64d3cf6 100644
--- a/tests/deltacloud/test_setup.rb
+++ b/tests/deltacloud/test_setup.rb
@@ -131,34 +131,11 @@ def deltacloud_test_file_names
   driver_collections.inject([]){|res, current| res << "deltacloud/#{TEST_FILES[current]}"
if TEST_FILES[current] ;res}
 end
 
-def create_a_bucket_and_blob
-  #random bucket and blob name - make sure starts with letter:
-  bucket_name = random_name
-  blob_name = random_name
-  #create bucket:
-  #  res = RestClient.post "#{API_URL}/buckets", {:name=>bucket_name}, {:Authorization=>BASIC_AUTH}
-  res = post("/buckets", :name=>bucket_name)
-  raise Exception.new("unable to create bucket with name #{bucket_name} for bucket_test.rb")
unless res.code == 201
-  #create blob:
-  res = RestClient.put "#{API_URL}/buckets/#{bucket_name}/#{blob_name}", "This is the test
blob content", {:Authorization=>BASIC_AUTH, :content_type=>"text/plain", "X-Deltacloud-Blobmeta-Version"=>"1.0",
"X-Deltacloud-Blobmeta-Author"=>"herpyderp"}
-  raise Exception.new("unable to create blob with name #{blob_name} for bucket_test.rb")
unless res.code == 200
-  return [bucket_name, blob_name]
-end
-
 def random_name
   name = rand(36**10).to_s(36)
   name.insert(0, "apitest")
 end
 
-def delete_bucket_and_blob(bucket, blob)
-  #  res = RestClient.delete "#{API_URL}/buckets/#{bucket}/#{blob}", {:Authorization=>BASIC_AUTH}
-  res = delete("/buckets/#{bucket}/#{blob}")
-  raise Exception.new("unable to delete blob with name #{blob} for bucket_test.rb") unless
res.code == 204
-  #  res = RestClient.delete "#{API_URL}/buckets/#{bucket}", {:Authorization=>BASIC_AUTH}
-  res = delete("/buckets/#{bucket}")
-  raise Exception.new("unable to delete bucket with name #{bucket} for bucket_test.rb") unless
res.code == 204
-end
-
 def discover_features
   res = xml_response(get("/"))
   features_hash = res.xpath("//api/link").inject({}) do |result, collection|


Mime
View raw message