Closed Tazaf closed 3 years ago
There are getters for most of the fields, the one for the default base URL was package-local which was just an oversight. I've made it public and will probably cut a release with a few other things this weekend.
As for using the Mocks, I don't think that's hacky at all. In fact it's the intent. In the end you really don't want to know the default URL, that alone is somewhat meaningless, you want to know that Unirest correctly assembled a full URL including the path and URL params. Testing behavior is more interesting than testing how a bunch of classes interact.
Hi @ryber
Sorry, you're right (obviously), I assumed there where no getters based only on the fact that the one I sought did not exist 😅 My Bad!
And about using Mocks, thanks for the explanation, that's pretty convincing 👍 Will use this pattern to test my custom config.
As usual, thanks for your availability. I'll close this issue as the initial requirements was not The Preferred Way.
That method is now public in 3.11.03
Is your feature request related to a problem? Please describe. I'm creating a new
UnirestInstance
in one of my class constructor and adding general config to it (base URL, headers, etc), and I'd like to write a test that checks that the actual configuration matches the expected one.Sadly, I apparently can't do that by comparing the properties since there's not getters on the
Config
instances.Describe the solution you'd like I'd like to know if there's a built-in way of comparing two
Config
objects (for example, one created by hand, the other get from theconfig()
method of aUnirestInstance
object).Describe alternatives you've considered I thought about testing the config by making a dummy call using
MockClient
, adding assertions to the mocked clientexpect()
method then callingverifyAll()
, but that feels... hacky,Additional context Here's a example of what I'd like to achieve:
Thanks!