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

more node tests

This commit is contained in:
Mike Hagedorn 2013-03-06 17:17:45 -06:00 committed by Rupak Ganguly
parent 82c8a89ef6
commit 60ecedfa60
3 changed files with 39 additions and 2 deletions

View file

@ -15,10 +15,24 @@ module Fog
class Mock
def get_load_balancer_node(load_balancer_id, node_id)
response = Excon::Response.new
if load_b = get_load_balancer(load_balancer_id).body
if node = find_node(load_b,node_id)
response.status = 200
response.body = node
else
raise Fog::HP::LB::NotFound
end
else
raise Fog::HP::LB::NotFound
end
response
end
def find_node(lb,node_id)
lb['nodes'].detect { |_| _['id'] == node_id }
end
end
end
end

View file

@ -0,0 +1,24 @@
Shindo.tests("Fog::HP::LB | get load balancer node", ['hp', 'lb', 'load_balancers', 'nodes']) do
@lb_format = {
'id' => String,
'address' => String,
'port' => String,
'condition' => String,
'status' => String,
}
tests('success') do
tests("#get_load_balancer_node").formats(@lb_format) do
HP[:lb].get_load_balancer_node('71','1041').body
end
end
tests('failure') do
tests("#get_load_balancer_node").raises (Fog::HP::LB::NotFound) do
HP[:lb].get_load_balancer_node('71', '0')
end
end
end

View file

@ -23,5 +23,4 @@ Shindo.tests("Fog::HP::LB | get load balancer", ['hp', 'lb', 'load_balancers'])
end
end