Is there a way to mock a non-responding http server
srizzling opened this issue · 2 comments
srizzling commented
Kinda counter-inituative, but I'm building a service that relies on getting an IP from the ec2-metadata endpoint trouble is that endpoint is only available when within AWS.
I have some logic that will branch, if you aren't in an AWS environment. However, I could write a unit that just calls the endpoint and watch it fail, but I feel as so there are side-effects (My unit test is probably running in AWS :P). Is there someway I can mock a non-responding server? i.e non-routable?
maxatome commented
You can try https://godoc.org/github.com/jarcoal/httpmock#NewErrorResponder with the appropriate error?
maxatome commented
Closing. Reopen if you didn't succeed in your quest.