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

55 lines
No EOL
2.2 KiB
Ruby

Shindo.tests('OpenStack | versions', ['openstack']) do
begin
@old_mock_value = Excon.defaults[:mock]
Excon.defaults[:mock] = true
Excon.stubs.clear
body = {
"versions" => [
{ "status" => "CURRENT", "id" => "v2.0", "links" => [ {
"href" => "http://example:9292/v2/",
"rel" => "self" }
]
},
{ "status" => "CURRENT", "id" => "v1.1", "links" => [ {
"href" => "http://exampple:9292/v1/",
"rel" => "self"
}
]
},
{ "status" => "SUPPORTED", "id"=>"v1.0", "links" => [ {
"href" => "http://example:9292/v1/",
"rel" => "self"
}
]
}
]
}
tests("supported") do
Excon.stub({ :method => 'GET' },
{ :status => 300, :body => Fog::JSON.encode(body) })
returns("v1.1") do
Fog::OpenStack.get_supported_version(/v1(\.(0|1))*/,
URI('http://example/'),
"authtoken")
end
end
tests("unsupported") do
Excon.stub({ :method => 'GET' },
{ :status => 300, :body => Fog::JSON.encode(body) })
raises(Fog::OpenStack::Errors::ServiceUnavailable) do
Fog::OpenStack.get_supported_version(/v3(\.(0|1))*/,
URI('http://example/'),
"authtoken")
end
end
ensure
Excon.stubs.clear
Excon.defaults[:mock] = @old_mock_value
end
end