Parent

Included Modules

Class/Module Index [+]

Quicksearch

GoogleTest::BucketsTest

Public Instance Methods

app() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 9
def app
  Sinatra::Application
end
test_01_it_can_create_new_bucket() click to toggle source

intentional typos here - bucket names cannot contain 'google' see code.google.com/apis/storage/docs/reference/v1/developer-guidev1.html

# File tests/drivers/google/buckets_test.rb, line 18
def test_01_it_can_create_new_bucket
   params = {
     :name => @@bucket_name_google,
     :'api[driver]' => 'google'
   }
   vcr_cassette = stable_vcr_cassette_name('post', '/api/buckets', params)
   post_url '/api/buckets', params, {'vcr_cassette'=>vcr_cassette}
   last_response.status.should == 201 # Created
   bucket = last_xml_response
   check_bucket_basics(bucket, "googel")
   (bucket/'bucket/size').first.text.should == "0"
 end
test_02_it_can_post_new_blob() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 31
def test_02_it_can_post_new_blob
  temp_file=File.open(@@created_blob_local_file)
  params = {
    'blob_id' => @@blob_name_google,
    :meta_params=>"2",
    :meta_name1=>"Author",
    :meta_value1=>"deltacloud",
    :meta_name2=>"foo",
    :meta_value2=>"bar",
    :'api[driver]' => 'google'
  }
  uri="/api/buckets/#{@@bucket_name_google}"
  vcr_cassette = stable_vcr_cassette_name('post', uri, params)
  params.merge!({'blob_data' => Rack::Test::UploadedFile.new(temp_file.path, "text/html")})
  post_url uri, params, {'vcr_cassette'=>vcr_cassette}
  last_response.status.should == 200
  blob= last_xml_response
  check_blob_basics(blob, "googel")
end
test_03_it_can_retrieve_named_bucket_details() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 51
def test_03_it_can_retrieve_named_bucket_details
   params = {
    :'api[driver]' => 'google'
  }
  get_url "/api/buckets/#{@@bucket_name_google}", params
  last_response.status.should == 200
  bucket = last_xml_response
  check_bucket_basics(bucket, "googel")
  (bucket/'bucket/size').first.text.should == "1" #assuming blob created succesfully right?
end
test_04_it_can_retrieve_named_blob_details() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 62
def test_04_it_can_retrieve_named_blob_details
  params = {
            :'api[driver]' => 'google'
           }
  get_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
  last_response.status.should == 200
  blob = last_xml_response
  check_blob_basics(blob, "googel")
  check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
end
test_05_it_can_retrieve_blob_metadata() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 73
def test_05_it_can_retrieve_blob_metadata
  params = {
            :'api[driver]' => 'google'
           }
  head_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
  last_response.status.should == 204
  blob_meta_hash = last_response.headers.inject({}){|result, (k,v)| result[k]=v if k=~/^X-Deltacloud-Blobmeta-/ ; result}
  blob_meta_hash.gsub_keys(/x-.*meta-/, "")
  ({"author"=>"deltacloud", "foo"=>"bar"}.eql?(blob_meta_hash)).should == true
end
test_06_it_can_update_blob_metadata() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 84
def test_06_it_can_update_blob_metadata
  params = {
            :'api[driver]' => 'google'
           }
  new_meta = {"X-Deltacloud-Blobmeta-author" => "ApacheDeltacloud", "X-Deltacloud-Blobmeta-oof" => "rab"}
  new_meta.each_pair do |k,v|
    header k, v
  end
  post_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
  last_response.status.should == 204
  new_meta.each_pair do |k,v|
    (last_response.headers[k]==v).should == true
  end
end
test_07_it_can_delete_blob() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 99
def test_07_it_can_delete_blob
  params = {
            :'api[driver]' => 'google'
           }
  delete_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
  last_response.status.should == 204
end
test_08_it_can_delete_bucket() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 107
def test_08_it_can_delete_bucket
  params = {
            :'api[driver]' => 'google'
           }
  delete_url "/api/buckets/#{@@bucket_name_google}", params
  last_response.status.should == 204
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.