Closed Bharathhere closed 5 years ago
Are you using the last version v1.0.4? Do you have a reproducible test?
Yes I am on version v1.0.4., To say I'm using it for BDD's and not for unit tests., I have two other mocks for different urls which are working fine but the one with custom client is not working and the error is dial tcp 127.0.0.1:8090: connect: connection refused
Without a small example of usage, it will be difficult to understand what happens in your case...
I am pretty sure that the client you are using the implementation might different from the one in the test. Or you are having two different instance of the client and that makes it impossible for httpmock to intercept the client request.
This got resolved for me. The client I have is not getting intercepted by using NonDefault so I set my clients transport to use the http default transport rester.DefaultTransport = httpmock.DefaultTransport
and used httpmock.Activate()
I'm using ActivateNonDefault for activating the mocks on my custom client but I see it not intercepting the calls. My client is using http.DefaultTransport for transport which I'm passing client := &http.Client{Transport: http.DefaultTransport} httpmock.ActivateNonDefault(client) while activating the client.,I also tried passing the way it is in documentation which did not help me., Can someone help me.,Thanks in advance!