Skip to content

Commit

Permalink
Merge pull request #18210 from yrudman/accept-hash-object-as-result-o…
Browse files Browse the repository at this point in the history
…f-inter-region-api-invocation

Accept Hash object as result of inter region api invocation
  • Loading branch information
carbonin authored Nov 16, 2018
2 parents ee71bab + 65aac7e commit 0f85990
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/mixins/inter_region_api_method_relay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def self.exec_api_call(region, collection_name, action, api_args = nil, id = nil
result.attributes
when ManageIQ::API::Client::Resource
instance_for_resource(result)
when Hash
# Some of API invocation returning Hash object
# Example: retire_resource for Service
_log.warn("remote API invocation returned Hash object")
result
else
raise InterRegionApiMethodRelayError, "Got unexpected API result object #{result.class}"
end
Expand Down
5 changes: 5 additions & 0 deletions spec/models/mixins/inter_region_api_method_relay_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ def expect_api_call(expected_action, expected_args = nil)
}.to raise_error(described_class::InterRegionApiMethodRelayError)
end

it "accepts Hash object as api result" do
expect(api_collection).to receive(action).and_return({})
expect { described_class.exec_api_call(region, collection_name, action) }.not_to raise_error
end

it "calls the given action with the given args" do
args = {:my => "args", :here => 123}
expect(api_collection).to receive(action).with(args).and_return(api_success_result)
Expand Down

0 comments on commit 0f85990

Please sign in to comment.