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

Added list tests, helper formats. Cleaned check_tests.

This commit is contained in:
Daniel Reichert 2013-07-17 11:05:39 -07:00 committed by Jay Faulkner
parent 6b82ecbb69
commit 231b11b910
6 changed files with 124 additions and 22 deletions

View file

@ -1,4 +1,4 @@
Shindo.tests('Fog::Rackspace::Monitoring | check_tests', ['rackspace','rackspacemonitoring']) do
Shindo.tests('Fog::Rackspace::Monitoring | check_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
@ -6,18 +6,7 @@ Shindo.tests('Fog::Rackspace::Monitoring | check_tests', ['rackspace','rackspace
check_id = nil
tests('success') do
tests('#create new check').formats(DATA_FORMAT) do
obj = {
:details => {
:url => 'http://www.rackspace.com',
:method => 'GET',
},
:type => "remote.http",
:monitoring_zones_poll => ["mzdfw"],
:target_hostname => 'rackspace.com',
:timeout => 30,
:period => 100
}
response = account.create_check(entity_id, obj).data
response = account.create_check(entity_id, CHECK_CREATE_OPTIONS).data
check_id = response[:headers]['X-Object-ID']
response
end

View file

@ -1,18 +1,26 @@
DELETE_HEADERS_FORMAT = {
'X-LB' => String,
'X-Response-Id' => String,
'X-RateLimit-Remaining' => String,
MINIMAL_HEADERS_FORMAT = {
'X-RateLimit-Window' => String,
'X-RateLimit-Limit' => String,
'X-RateLimit-Type' => String,
'Content-Type' => String,
'Date' => String,
'X-RateLimit-Limit' => String,
'Content-Length' => String
}
HEADERS_FORMAT = DELETE_HEADERS_FORMAT.merge({
'X-Object-ID' => String,
'Location' => String,
DELETE_HEADERS_FORMAT = MINIMAL_HEADERS_FORMAT.merge({
'Content-Length' => String
})
HEADERS_FORMAT = MINIMAL_HEADERS_FORMAT.merge({
'Content-Length' => String,
'X-Object-ID' => String,
'Location' => String
})
LIST_HEADERS_FORMAT = MINIMAL_HEADERS_FORMAT.merge({
'X-RateLimit-Remaining' => String,
'X-Response-Id' => String,
'Transfer-Encoding' => String,
'X-LB' => String,
'Vary' => String
})
DATA_FORMAT = {
:status => Integer,
:body => String,
@ -25,3 +33,46 @@ DELETE_DATA_FORMAT = {
:headers => DELETE_HEADERS_FORMAT,
:remote_ip => String
}
CHECK_CREATE_OPTIONS = {
:details => {
:url => 'http://www.rackspace.com',
:method => 'GET',
},
:type => 'remote.http',
:monitoring_zones_poll => ['mzdfw'],
:target_hostname => 'rackspace.com',
:timeout => 30,
:period => 100
}
OVERVIEW_FORMAT = {
:status => Integer,
:body=> {
:values => [
{
:entity => {
:id => String,
:label => String,
:ip_addresses => { },
:metadata => String
},
:checks => [
],
:alarms => [
],
:latest_alarm_states => [
]
}
],
:metadata => {
:count => Integer,
:limit => Integer,
:marker => String,
:next_marker => String,
:next_href => String
}
},
:headers => LIST_HEADERS_FORMAT,
:remote_ip => String
}

View file

@ -0,0 +1,15 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_check_type_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get check types').formats(LIST_HEADERS_FORMAT) do
account.list_check_types().data[:headers]
end
end
tests('failure') do
tests('#fail to list check types').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_check_types(-1)
end
end
end

View file

@ -0,0 +1,17 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_checks_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]
tests('success') do
tests('#get list of checks').formats(LIST_HEADERS_FORMAT) do
account.list_checks(entity_id).data[:headers]
end
end
tests('failure') do
tests('#fail to list checks').raises(Fog::Rackspace::Monitoring::NotFound) do
account.list_checks(-1)
end
end
account.delete_entity(entity_id)
end

View file

@ -0,0 +1,15 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_entities_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get list of entities').formats(CHECKS_HEADERS_FORMAT) do
account.list_entities().data[:headers]
end
end
tests('failure') do
tests('#fail to list entities').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_entities(-1)
end
end
end

View file

@ -0,0 +1,15 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_overview_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get list overview').formats(OVERVIEW_HEADERS_FORMAT) do
account.list_overview().data[:headers]
end
end
tests('failure') do
tests('#fail to list overview').raises(Fog::Rackspace::Monitoring::NoMethodError) do
account.list_overview(-1)
end
end
end