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:
parent
82c8a89ef6
commit
60ecedfa60
3 changed files with 39 additions and 2 deletions
|
@ -15,10 +15,24 @@ module Fog
|
||||||
class Mock
|
class Mock
|
||||||
def get_load_balancer_node(load_balancer_id, node_id)
|
def get_load_balancer_node(load_balancer_id, node_id)
|
||||||
response = Excon::Response.new
|
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
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_node(lb,node_id)
|
||||||
|
lb['nodes'].detect { |_| _['id'] == node_id }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
24
tests/hp/requests/lb/get_load_balancer_node_tests.rb
Normal file
24
tests/hp/requests/lb/get_load_balancer_node_tests.rb
Normal 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
|
|
@ -23,5 +23,4 @@ Shindo.tests("Fog::HP::LB | get load balancer", ['hp', 'lb', 'load_balancers'])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue