Sha256: 8e4e0e2e0a258135bd4670051db285cd53a8807d09857bbbf96ed46f0a998a84

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

require 'rubygems'
require 'require_relative' if RUBY_VERSION < '1.9'

require_relative File.join('..', 'common.rb')

describe Deltacloud::Collections::Buckets do

  before do
    def app; run_frontend; end
    authorize 'mockuser', 'mockpassword'
    @collection = Deltacloud::Collections.collection(:buckets)
  end

  it 'has index operation' do
    @collection.operation(:index).must_equal Sinatra::Rabbit::BucketsCollection::IndexOperation
  end

  it 'provides URL to specify new bucket' do
    header 'Accept', 'text/html'
    get root_url + '/buckets/new/' + Deltacloud::Helpers::Application::NEW_BLOB_FORM_ID
    status.must_equal 200
  end

  it 'returns list of buckets in various formats with index operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/buckets'
      status.must_equal 200
    end
  end

  it 'must support creating a new bucket and destroying it' do
    post root_url + '/buckets', { :name => 'test-bucket1' }
    status.must_equal 201
    xml.root.name.must_equal 'bucket'
    delete root_url + '/buckets/' + xml.root[:id]
    status.must_equal 204
  end

  it 'returns blob metadata' do
    head root_url + '/buckets/bucket1/blob1'
    headers['X-Deltacloud-Blobmeta-SOMENEWKEY'].must_equal 'NEWVALUE'
    status.must_equal 204
    head root_url + '/buckets/bucket1/non-existing-blob'
    status.must_equal 404
  end

  it 'returns blob details on show operation in various formats' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/buckets/bucket1/blob1'
      last_response
      status.must_equal 200
    end
  end

  it 'creates a new blob and then destroy it' do
    post root_url + '/buckets/bucket1', { :blob_id => 'test-blob', :blob_data => 'test', :meta_params => '1', :meta_name1 => 'test-meta1' }
    status.must_equal 201
    delete root_url + '/buckets/bucket1/test-blob'
    status.must_equal 204
  end

  it 'properly serialize attributes in JSON' do
    check_json_serialization_for :bucket, 'bucket1'
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.1.1 tests/deltacloud/collections/buckets_collection_test.rb
deltacloud-core-1.1.0 tests/deltacloud/collections/buckets_collection_test.rb