From 60ecedfa60499d76bd3117c5d124881fbc1216e5 Mon Sep 17 00:00:00 2001 From: Mike Hagedorn Date: Wed, 6 Mar 2013 17:17:45 -0600 Subject: [PATCH] more node tests --- .../hp/requests/lb/get_load_balancer_node.rb | 16 ++++++++++++- .../lb/get_load_balancer_node_tests.rb | 24 +++++++++++++++++++ .../hp/requests/lb/get_load_balancer_tests.rb | 1 - 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/hp/requests/lb/get_load_balancer_node_tests.rb diff --git a/lib/fog/hp/requests/lb/get_load_balancer_node.rb b/lib/fog/hp/requests/lb/get_load_balancer_node.rb index cd412ebf9..853a91dbf 100644 --- a/lib/fog/hp/requests/lb/get_load_balancer_node.rb +++ b/lib/fog/hp/requests/lb/get_load_balancer_node.rb @@ -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 diff --git a/tests/hp/requests/lb/get_load_balancer_node_tests.rb b/tests/hp/requests/lb/get_load_balancer_node_tests.rb new file mode 100644 index 000000000..7fe915758 --- /dev/null +++ b/tests/hp/requests/lb/get_load_balancer_node_tests.rb @@ -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 \ No newline at end of file diff --git a/tests/hp/requests/lb/get_load_balancer_tests.rb b/tests/hp/requests/lb/get_load_balancer_tests.rb index 292f8fa6d..2302a94bf 100644 --- a/tests/hp/requests/lb/get_load_balancer_tests.rb +++ b/tests/hp/requests/lb/get_load_balancer_tests.rb @@ -23,5 +23,4 @@ Shindo.tests("Fog::HP::LB | get load balancer", ['hp', 'lb', 'load_balancers']) end - end \ No newline at end of file