mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Removed location specific functionality; Green for Mock tests
This commit is contained in:
parent
bdd2ca3094
commit
7a8b5fda10
6 changed files with 2 additions and 101 deletions
|
@ -10,8 +10,8 @@ module Fog
|
|||
model Fog::Google::Storage::Directory
|
||||
|
||||
def all
|
||||
# data = connection.get_service.body['Buckets']
|
||||
# load(data)
|
||||
data = connection.get_service.body['Buckets']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(key, options = {})
|
||||
|
|
|
@ -22,16 +22,6 @@ module Fog
|
|||
false
|
||||
end
|
||||
|
||||
def location
|
||||
requires :key
|
||||
data = connection.get_bucket_location(key)
|
||||
data.body['LocationConstraint']
|
||||
end
|
||||
|
||||
def location=(new_location)
|
||||
@location = new_location
|
||||
end
|
||||
|
||||
def files
|
||||
@files ||= begin
|
||||
Fog::Google::Storage::Files.new(
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
module Fog
|
||||
module Google
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
require 'fog/google/parsers/storage/get_bucket_location'
|
||||
|
||||
# Get location constraint for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get location constraint for
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'LocationConstraint'<~String> - Location constraint of the bucket
|
||||
def get_bucket_location(bucket_name)
|
||||
request({
|
||||
:expects => 200,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:idempotent => true,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Google::Storage::GetBucketLocation.new,
|
||||
:query => {'location' => nil}
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_bucket_location(bucket_name)
|
||||
response = Excon::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,7 +16,6 @@ module Fog
|
|||
request :delete_object
|
||||
request :get_bucket
|
||||
request :get_bucket_acl
|
||||
request :get_bucket_location
|
||||
request :get_bucket_logging
|
||||
request :get_bucket_object_versions
|
||||
request :get_bucket_versioning
|
||||
|
|
|
@ -39,16 +39,6 @@ describe 'Fog::Google::Storage::Directory' do
|
|||
|
||||
end
|
||||
|
||||
describe "#location" do
|
||||
|
||||
it "should return the location constraint" do
|
||||
directory = Google[:storage].directories.create(:key => 'fogmodeleudirectory', :location => 'EU')
|
||||
directory.location.should == 'EU'
|
||||
Google[:eu_storage].directories.get('fogmodeleudirectory').destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#payer" do
|
||||
|
||||
it "should return the request payment value" do
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Storage.get_bucket_location' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
Google[:storage].put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
Google[:eu_storage].delete_bucket('foggetlocation')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = Google[:storage].get_bucket_location('foggetlocation')
|
||||
actual.status.should == 200
|
||||
actual.body['LocationConstraint'].should == 'EU'
|
||||
end
|
||||
|
||||
end
|
||||
describe 'failure' do
|
||||
|
||||
it 'should raise NotFound error if bucket does not exist' do
|
||||
lambda {
|
||||
Google[:storage].get_bucket_location('fognotabucket')
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue