1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

starting to fill in pending rackspace files tests

This commit is contained in:
Wesley Beary 2009-11-05 00:02:26 -08:00
parent 9ecb6f8a86
commit 9eaf469e99
7 changed files with 31 additions and 15 deletions

View file

@ -59,9 +59,10 @@ module Fog
}, },
:host => @cdn_host, :host => @cdn_host,
:method => params[:method], :method => params[:method],
:path => "#{@cdn_path}/#{params[:path]}" :path => "#{@cdn_path}/#{params[:path]}",
:query => params[:query]
}) })
unless response.status == 204 unless response.body.empty?
response.body = JSON.parse(response.body) response.body = JSON.parse(response.body)
end end
response response
@ -76,9 +77,10 @@ module Fog
}, },
:host => @storage_host, :host => @storage_host,
:method => params[:method], :method => params[:method],
:path => "#{@storage_path}/#{params[:path]}" :path => "#{@storage_path}/#{params[:path]}",
:query => params[:query]
}) })
unless response.status == 204 unless response.body.empty?
response.body = JSON.parse(response.body) response.body = JSON.parse(response.body)
end end
response response

View file

@ -20,7 +20,7 @@ unless Fog.mocking?
# * 'name'<~String>: - Name of container # * 'name'<~String>: - Name of container
def get_containers(options = {}) def get_containers(options = {})
options = { 'format' => 'json' }.merge!(options) options = { 'format' => 'json' }.merge!(options)
query = [] query = ''
for key, value in options for key, value in options
query << "#{key}=#{CGI.escape(value)}&" query << "#{key}=#{CGI.escape(value)}&"
end end
@ -31,9 +31,6 @@ unless Fog.mocking?
:path => '', :path => '',
:query => query :query => query
) )
if response.status == 204
response.body = []
end
response response
end end

View file

@ -11,7 +11,7 @@ unless Fog.mocking?
# #
def put_container(name) def put_container(name)
response = storage_request( response = storage_request(
:expects => 201, :expects => [201, 202],
:method => 'PUT', :method => 'PUT',
:path => CGI.escape(name) :path => CGI.escape(name)
) )

View file

@ -3,9 +3,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Rackspace::Files.delete_container' do describe 'Rackspace::Files.delete_container' do
describe 'success' do describe 'success' do
before(:each) do
files.put_container('container_name')
end
it "should return proper attributes" do it "should return proper attributes" do
pending files.delete_container('container_name')
p files.delete_container(container_name)
end end
end end

View file

@ -5,7 +5,7 @@ describe 'Rackspace::Files.get_container' do
it "should return proper attributes" do it "should return proper attributes" do
pending pending
p files.get_container(container_name) files.get_container(container_name)
end end
end end

View file

@ -3,8 +3,19 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Rackspace::Files.get_containers' do describe 'Rackspace::Files.get_containers' do
describe 'success' do describe 'success' do
before(:each) do
files.put_container('container_name')
end
after(:each) do
files.delete_container('container_name')
end
it "should return proper attributes" do it "should return proper attributes" do
p files.get_containers actual = files.get_containers.body
actual.first['bytes'].should be_an(Integer)
actual.first['count'].should be_an(Integer)
actual.first['name'].should be_a(String)
end end
end end

View file

@ -3,9 +3,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Rackspace::Files.put_container' do describe 'Rackspace::Files.put_container' do
describe 'success' do describe 'success' do
after(:each) do
files.delete_container('container_name')
end
it "should return proper attributes" do it "should return proper attributes" do
pending files.put_container('container_name')
p files.put_container(container_name)
end end
end end