mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|databases] Handle breaking API changes.
This commit is contained in:
parent
e1c04da5ab
commit
868eb355ad
2 changed files with 15 additions and 96 deletions
|
@ -1,77 +0,0 @@
|
|||
Shindo.tests('Fog::Rackspace::Database | instance_tests', ['rackspace']) do
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
@service = Fog::Rackspace::Databases.new
|
||||
|
||||
LINK_FORMAT = [{'href' => String, 'rel' => String}]
|
||||
|
||||
DATABASE_INSTANCE_FORMAT = {
|
||||
'created' => String,
|
||||
'flavor' => {
|
||||
'id' => String,
|
||||
'links' => LINK_FORMAT
|
||||
},
|
||||
'hostname' => String,
|
||||
'id' => String,
|
||||
'links' => LINK_FORMAT,
|
||||
'name' => String,
|
||||
'status' => String,
|
||||
'updated' => String,
|
||||
'volume' => { 'size' => Integer},
|
||||
}
|
||||
DATABASE_CREATE_INSTANCE_FORMAT = {
|
||||
'instance' => DATABASE_INSTANCE_FORMAT
|
||||
}
|
||||
DATABASE_GET_INSTANCE_FORMAT = {
|
||||
'instance' => DATABASE_INSTANCE_FORMAT.merge({'rootEnabled' => Fog::Boolean, 'volume' => {'size' => Integer, 'used' => Float}})
|
||||
}
|
||||
DATABASE_LIST_INSTANCES_FORMAT = {
|
||||
'instances' => [
|
||||
DATABASE_INSTANCE_FORMAT
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
tests('success') do
|
||||
|
||||
@db_id = nil
|
||||
@db_name = 'fog' + Time.now.to_i.to_s
|
||||
|
||||
tests("#create_instance(#{@db_name}, 1, 1)").formats(DATABASE_CREATE_INSTANCE_FORMAT) do
|
||||
data = @service.create_instance(@db_name, 1, 1).body
|
||||
@db_id = data['instance']['id']
|
||||
data
|
||||
end
|
||||
|
||||
until @service.get_instance(@db_id).body["instance"]["status"] == 'ACTIVE'
|
||||
sleep 10
|
||||
end
|
||||
|
||||
tests("#list_instances_details").formats(DATABASE_LIST_INSTANCES_FORMAT) do
|
||||
data = @service.list_instances_details.body
|
||||
puts data.inspect
|
||||
data
|
||||
end
|
||||
|
||||
tests("#get_instance(#{@db_id}").formats(DATABASE_GET_INSTANCE_FORMAT) do
|
||||
@service.get_instance(@db_id).body
|
||||
end
|
||||
|
||||
tests("#delete_instance(#{@db_id})").succeeds do
|
||||
@service.delete_instance(@db_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#create_instance('', 0, 0) => Invalid Create Critera").raises(Fog::Rackspace::Databases::BadRequest) do
|
||||
@service.create_instance('', 0, 0)
|
||||
end
|
||||
|
||||
tests("#get_instance('') => Does not exist").raises(Fog::Rackspace::Databases::NotFound) do
|
||||
@service.get_instance('')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -3,22 +3,19 @@ LINKS_FORMAT = [{
|
|||
'rel' => String
|
||||
}]
|
||||
|
||||
FLAVOR_FORMAT = {
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'ram' => Integer,
|
||||
'links' => LINKS_FORMAT
|
||||
}
|
||||
|
||||
GET_FLAVOR_FORMAT = {
|
||||
'flavor' => {
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'ram' => Integer,
|
||||
'vcpus' => Integer,
|
||||
'links' => LINKS_FORMAT
|
||||
}
|
||||
'flavor' => FLAVOR_FORMAT
|
||||
}
|
||||
|
||||
LIST_FLAVORS_FORMAT = {
|
||||
'flavors' => [
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'links' => LINKS_FORMAT
|
||||
]
|
||||
'flavors' => [FLAVOR_FORMAT]
|
||||
}
|
||||
|
||||
INSTANCE_FORMAT = {
|
||||
|
@ -26,12 +23,6 @@ INSTANCE_FORMAT = {
|
|||
'name' => String,
|
||||
'status' => String,
|
||||
'links' => LINKS_FORMAT,
|
||||
}
|
||||
|
||||
INSTANCE_DETAILS_FORMAT = INSTANCE_FORMAT.merge({
|
||||
'created' => String,
|
||||
'updated' => String,
|
||||
'hostname' => String,
|
||||
'flavor' => {
|
||||
'id' => String,
|
||||
'links' => LINKS_FORMAT
|
||||
|
@ -39,6 +30,12 @@ INSTANCE_DETAILS_FORMAT = INSTANCE_FORMAT.merge({
|
|||
'volume' => {
|
||||
'size' => Integer
|
||||
}
|
||||
}
|
||||
|
||||
INSTANCE_DETAILS_FORMAT = INSTANCE_FORMAT.merge({
|
||||
'created' => String,
|
||||
'updated' => String,
|
||||
'hostname' => String,
|
||||
})
|
||||
|
||||
CREATE_INSTANCE_FORMAT = {
|
||||
|
@ -47,7 +44,6 @@ CREATE_INSTANCE_FORMAT = {
|
|||
|
||||
GET_INSTANCE_FORMAT = {
|
||||
'instance' => INSTANCE_DETAILS_FORMAT.merge({
|
||||
'rootEnabled' => Fog::Boolean,
|
||||
'volume' => {
|
||||
'size' => Integer,
|
||||
'used' => Float
|
||||
|
|
Loading…
Reference in a new issue