jarcoal / httpmock

HTTP mocking for Golang
http://godoc.org/github.com/jarcoal/httpmock
MIT License
1.93k stars 103 forks source link

Is there a way to mock a non-responding http server #58

Closed srizzling closed 4 years ago

srizzling commented 5 years ago

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 5 years ago

You can try https://godoc.org/github.com/jarcoal/httpmock#NewErrorResponder with the appropriate error?

maxatome commented 4 years ago

Closing. Reopen if you didn't succeed in your quest.