Sha256: ccf1c0d46be4c9bc4fff7b6f4b7f0a8dfca109f34ee8bc32a13e4bca77494736

Contents?: true

Size: 1.98 KB

Versions: 14

Compression:

Stored size: 1.98 KB

Contents

Shindo.tests("Fog::Storage[:google] | bucket requests", ["google"]) do
  tests("success") do
    @bucket_format = {
      "CommonPrefixes" => [],
      "IsTruncated"     => Fog::Boolean,
      "Marker"          => NilClass,
      "Name"            => String,
      "Prefix"          => NilClass,
      "Contents"        => [{
        "ETag"          => String,
        "Key"           => String,
        "LastModified"  => Time,
        "Owner" => {
          "DisplayName" => String,
          "ID"          => String
        },
        "Size" => Integer
      }]
    }

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

    tests("#put_bucket('fogbuckettests')").succeeds do
      Fog::Storage[:google].put_bucket("fogbuckettests")
    end

    tests("#get_service").formats(@service_format) do
      Fog::Storage[:google].get_service.body
    end

    file = Fog::Storage[:google].directories.get("fogbuckettests").files.create(:body => "y", :key => "x")

    tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
      Fog::Storage[:google].get_bucket("fogbuckettests").body
    end

    file.destroy

    tests("#delete_bucket('fogbuckettests')").succeeds do
      Fog::Storage[:google].delete_bucket("fogbuckettests")
    end
  end

  tests("failure") do
    tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
      Fog::Storage[:google].delete_bucket("fognonbucket")
    end

    @bucket = Fog::Storage[:google].directories.create(:key => "fognonempty")
    @file = @bucket.files.create(:key => "foo", :body => "bar")

    tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do
      Fog::Storage[:google].delete_bucket("fognonempty")
    end

    @file.destroy
    @bucket.destroy

    tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
      Fog::Storage[:google].get_bucket("fognonbucket")
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 tests/requests/storage/bucket_tests.rb
fog-google-0.5.5 tests/requests/storage/bucket_tests.rb
fog-google-0.5.4 tests/requests/storage/bucket_tests.rb
fog-google-0.5.3 tests/requests/storage/bucket_tests.rb
fog-google-0.5.2 tests/requests/storage/bucket_tests.rb
fog-google-0.5.1 tests/requests/storage/bucket_tests.rb
fog-google-0.5.0 tests/requests/storage/bucket_tests.rb
fog-google-0.4.2 tests/requests/storage/bucket_tests.rb
fog-google-0.4.1 tests/requests/storage/bucket_tests.rb
fog-google-0.4.0 tests/requests/storage/bucket_tests.rb
fog-google-0.3.2 tests/requests/storage/bucket_tests.rb
fog-google-0.3.1 tests/requests/storage/bucket_tests.rb
fog-google-0.3.0 tests/requests/storage/bucket_tests.rb
fog-google-0.2.0 tests/requests/storage/bucket_tests.rb