1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
require "test_helper"
describe "Fog::OpenStack::Storage | container requests" do
def cleanup_container
return if Fog.mocking?
if @storage.head_container(@container_name)
@storage.delete_container(@container_name)
end
rescue Fog::OpenStack::Storage::NotFound
end
before do
@storage = Fog::OpenStack::Storage.new
@container_format = [String]
@container_name = 'fogcontainertests'
cleanup_container
@containers_format = [{
'bytes' => Integer,
'count' => Integer,
'name' => String
}]
end
after do
cleanup_container
end
describe "success" do
it "#put_container('fogcontainertests')" do
unless Fog.mocking?
@storage.put_container('fogcontainertests').status.must_equal 201
end
end
describe "using container" do
before do
unless Fog.mocking?
@storage.put_container(@container_name).status.must_equal 201
end
end
after do
cleanup_container
end
it "#get_container('fogcontainertests')" do
unless Fog.mocking?
@storage.get_container('fogcontainertests').body.must_match_schema(@container_format)
end
end
it "#get_containers" do
unless Fog.mocking?
@storage.get_containers.body.must_match_schema(@containers_format)
end
end
it "#head_container('fogcontainertests')" do
unless Fog.mocking?
resp = @storage.head_container('fogcontainertests')
resp.status.must_equal 204
resp.headers['X-Container-Object-Count'].to_i.must_equal 0
end
end
it "#head_containers" do
unless Fog.mocking?
resp = @storage.head_containers
resp.status.must_equal 204
resp.headers['X-Account-Container-Count'].to_i.must_equal 1
end
end
it "#delete_container('fogcontainertests')" do
unless Fog.mocking?
@storage.delete_container('fogcontainertests').status.must_equal 204
end
end
end
end
describe "failure" do
it "#get_container('fognoncontainer')" do
unless Fog.mocking?
proc do
@storage.get_container('fognoncontainer')
end.must_raise Fog::OpenStack::Storage::NotFound
end
end
it "#head_container('fognoncontainer')" do
unless Fog.mocking?
proc do
@storage.head_container('fognoncontainer')
end.must_raise Fog::OpenStack::Storage::NotFound
end
end
it "#delete_container('fognoncontainer')" do
unless Fog.mocking?
proc do
@storage.delete_container('fognoncontainer')
end.must_raise Fog::OpenStack::Storage::NotFound
end
end
end
end
|