Closed tumido closed 6 years ago
cc @abonas
Note: the allow_any_instance_of
is used due to necessity to raise exceptions when the ::Hawkular::Client
is already instantiated. The exception handling happens later in the code so we can't raise errors on :new
. The way to avoid such allow_any_instance_of
call would be:
let(:client) { ::Hawkular::Client.new(:entrypoint => "", :credentials => {}, :options => {}) }
...
before do
allow(::Hawkular::Client).to receive(:new).and_return(client)
end
...
it "invalid credentials" do
allow(client).to receive(:inventory).and_raise(...)
except...
end
If this is prefered by the team, I'm ok to change it. Though I personally prefer to have the ::Hawkular::Client
instantiated by the MiddlewareManager instead of mocking it. This would help in cases when an exception on client becomes risen during the :new
call. The mocking of whole client may hide it.
@miq-bot assign @cfcosta please review, thanks! ;)
@miq-bot add_label test
@cfcosta, the part in your review about mocks - you're referring to the first part only (testing the connection) or also to the second part (for the credentials validation)?
@tumido for credential validations is a little better, I think a better way to do so is to actually inject the connection class into the method as an optional parameter. Then at least we can remove the dependency on allow_any_instance_of
.
@cfcosta, @israel-hdez, I did a second iteration of this, which completely rewrites it and makes it able to compare against client's internal @state
. Can you please review it for me? Also, it still depends on the https://github.com/ManageIQ/manageiq-providers-hawkular/pull/100 so it will fail for raw_connect
.
@miq-bot add_label gaprindashvili/no
To merge this, #100 needs to go in. Is it ready? Reading the comments on it, I'm not sure.
Closing, won't merge. Repo abandoned. :no_entry:
Enhance test coverage of
MiddlewareManager
to provide test cases for::connect
method using non-ssl and ssl verification:verify_credentials
and:raw_connect
covering the exception mappingBased on suggestion by @israel-hdez here. A bit of competition PR to https://github.com/ManageIQ/manageiq-providers-hawkular/pull/86 from @aljesus, replacing 4 test cases with more generic ones.
Depends on https://github.com/ManageIQ/manageiq-providers-hawkular/pull/100