Sha256: 768e4ec081aee2d87291dff073b52d60c63e8b5c917c250bca7e148f64314a86

Contents?: true

Size: 1.96 KB

Versions: 12

Compression:

Stored size: 1.96 KB

Contents

Shindo.tests('Google::Storage | bucket requests', ['google']) do

  tests('success') do

    @bucket_format = {
      'IsTruncated' => Fog::Boolean,
      'Marker'      => NilClass,
      'Name'        => String,
      'Prefix'      => NilClass,
      'Contents'    => [{
        'ETag'          => String,
        'Key'           => String,
        'LastModified'  => Time,
        'Owner' => {
          'DisplayName' => String,
          'ID'          => String
        },
        'Size' => Integer,
        'StorageClass' => String
      }]
    }

    @service_format = {
      'Buckets' => [{
        'CreationDate'  => Time,
        'Name'          => String,
      }],
      'Owner'   => {
        'DisplayName' => String,
        'ID'          => String
      }
    }

    tests("#put_bucket('fogbuckettests')").succeeds do
      Google[:storage].put_bucket('fogbuckettests')
    end

    tests("#get_service").formats(@service_format) do
      Google[:storage].get_service.body
    end

    file = Google[:storage].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x')

    tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
      Google[:storage].get_bucket('fogbuckettests').body
    end

    file.destroy

    tests("#delete_bucket('fogbuckettests')").succeeds do
      Google[:storage].delete_bucket('fogbuckettests')
    end

  end

  tests('failure') do

    tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
      Google[:storage].delete_bucket('fognonbucket')
    end

    @bucket = Google[:storage].directories.create(:key => 'fognonempty')
    @file = @bucket.files.create(:key => 'foo', :body => 'bar')

    tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do
      Google[:storage].delete_bucket('fognonempty')
    end

    @file.destroy
    @bucket.destroy

    tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
      Google[:storage].get_bucket('fognonbucket')
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fog-0.3.29 tests/google/requests/storage/bucket_tests.rb
fog-0.3.28 tests/google/requests/storage/bucket_tests.rb
fog-0.3.27 tests/google/requests/storage/bucket_tests.rb
fog-0.3.26 tests/google/requests/storage/bucket_tests.rb
fog-0.3.25 tests/google/requests/storage/bucket_tests.rb
fog-0.3.24 tests/google/requests/storage/bucket_tests.rb
fog-0.3.23 tests/google/requests/storage/bucket_tests.rb
fog-0.3.22 tests/google/requests/storage/bucket_tests.rb
fog-0.3.21 tests/google/requests/storage/bucket_tests.rb
fog-0.3.20 tests/google/requests/storage/bucket_tests.rb
fog-0.3.19 tests/google/requests/storage/bucket_tests.rb
fog-0.3.18 tests/google/requests/storage/bucket_tests.rb