Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge "retore gateway client spec."

  • Loading branch information...
commit b8955fd19a03dba382ef3e5b022ed7688254bce8 2 parents 290430f + 137ee52
@andl andl authored Gerrit Code Review committed
Showing with 34 additions and 0 deletions.
  1. +34 −0 spec/unit/service_gateway_client_spec.rb
View
34 spec/unit/service_gateway_client_spec.rb
@@ -53,5 +53,39 @@ class ServiceGatewayClient
result = client.perform_request(http_method, path)
result.should == message
end
+
+
+ it "should should raise error with none 200 response" do
+ client = VCAP::Services::Api::ServiceGatewayClient.new(@url, @token, @timeout)
+ EM.should_receive(:reactor_running?).any_number_of_times.and_return nil
+
+ path = "/path1"
+ resp = mock("resq")
+ resp.should_receive(:body).and_return(
+ {:code => 40400, :description=> "not found"}.to_json,
+ {:code => 50300, :description=> "internal"}.to_json,
+ {:code => 50100, :description=> "not done yet"}.to_json,
+ {:bad_response => "foo"}.to_json,
+ )
+ resp.should_receive(:code).and_return(404, 503, 500, 500)
+ resp.should_receive(:start).any_number_of_times.and_return resp
+
+ http_method = :get
+
+ Net::HTTP.should_receive(:new).with("localhost", 80).any_number_of_times.and_return resp
+
+ expect {
+ client.perform_request(http_method, path)
+ }.to raise_error(VCAP::Services::Api::ServiceGatewayClient::NotFoundResponse)
+ expect {
+ client.perform_request(http_method, path)
+ }.to raise_error(VCAP::Services::Api::ServiceGatewayClient::GatewayInternalResponse)
+ expect {
+ client.perform_request(http_method, path)
+ }.to raise_error(VCAP::Services::Api::ServiceGatewayClient::ErrorResponse, /not done yet/)
+ expect {
+ client.perform_request(http_method, path)
+ }.to raise_error(VCAP::Services::Api::ServiceGatewayClient::UnexpectedResponse)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.