Releases: jarcoal/httpmock
Releases · jarcoal/httpmock
v1.3.1
v1.3.0
New features:
- new matcher feature, allowing to create a Responder based on net/http.Request content (header or body for example), so not only on method and URL as before. See the following new registering functions & methods:
- add following Responder methods, allowing to easily add some headers to the returned net/http.Response without the need to craft a Responder by hand:
Miscellaneous:
- documentation now uses new go1.19 doc features;
- go minimal version required is now 1.13;
- CI tests using go1.20 & golangci-lint v1.51.0.
v1.2.0
New features:
NewNotFoundResponder
helps to detect a possible path mistake (final/
or double/
cases);- add
(*MockTransport).Responders
method allowing to list registered responders.
Fixes:
-
url.RawPath
is used instead ofurl.Path
when checking path alone for consistency with full URL check, which is always unescaped.
Let 2 registered responders:GET http://z.tld/foo%2fbar
GET /foo%2fbar
Before this release:
GET http://z.tld/foo%2fbar
is caught by 1GET http://unknown.tld/foo%2fbar
is not caught as the tested path is/foo/bar
instead of/foo%2fbar
From this release:
GET http://z.tld/foo%2fbar
is caught by 1GET http://unknown.tld/foo%2fbar
is caught by 2
-
save of old clients transports is now protected from concurrent writes (@roboslone).
Miscellaneous:
- now use go-testdeep to simplify tests (saves >500 test lines);
- go minimal version required is now 1.9;
- CI tests using go1.18 & golangci-lint v1.45.0;
- signatures (and so documentation) now use
any
type instead ofinterface{}
, as appeared in go 1.18 (in a compatible manner with go<1.18).
Enjoy!
v1.1.0
New features:
- tell the user about possible mistakes concerning the mocked HTTP method;
- by default, registering a
Responder
for a lower-cased method amongCONNECT
,DELETE
,GET
,HEAD
,OPTIONS
,POST
,PUT
andTRACE
, produces a panic as it is probably a mistake. This behavior can be disabled by setting newMockTransport.DontCheckMethod
field totrue
prior to theRegister*Responder*()
call; - registering a
nil
Responder
now unregisters it and zeroes its statistics; - add
Responder
methods:Delay(time.Duration)
to delay a response,Then(Responder)
to chain responders.
Fix:
- net/http and httpmock issued
Response.Body
are now consistent. Now, the httpmock one can only be read once: if some code wrongly depends onNewStringResponse()
&NewBytesResponse()
response body be read ad infinitum, it should be changed to either recallNewStringResponse()
&NewBytesResponse()
before reading again the response body, or useNewStringResponder()
&NewBytesResponder()
.
Doc:
- document that (re-)registering a
Responder
zeroes its statistics.
Enjoy!
v1.0.8
v1.0.7
New feature:
- add
File
type allowing to easily serve files contents
Fix:
- race condition in
GetCallCountInfo()
thanks to @swithek
Misc:
- test coverage increased almost 100% (OK 99.843% :) )
- code reorganized
- more linters involved
- documentation updated
- examples style normalized
- CI now use github actions instead of travis
Enjoy!
v1.0.6
v1.0.5
v1.0.4
Add regexp responders feature.
To register a regexp responder, see:
- RegisterResponder & MockTransport.RegisterResponder with url prefixed with "=~"
- new RegisterRegexpResponder & MockTransport.RegisterRegexpResponder
And to help writing custom responders, new functions: