Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.13→1.0Release Notes
lipanski/mockito (mockito)
v1.7.2Compare Source
v1.7.1Compare Source
v1.7.0Compare Source
parking_lotoptionalrandcrate to v0.9coloredcrate v3Thanks to @tottoto @nerodono
v1.6.1Compare Source
Mock::with_header_from_requestallowing you to set the header dynamically by using a closure which exposes theRequestobjectThanks to @alex-kattathra-johnson
v1.6.0Compare Source
Mock::match_requestwhich exposes theRequestobject via a closure and can be used to build custom matchersv1.5.0Compare Source
Thanks to @tottoto
v1.4.0Compare Source
coloredcratev1.3.1Compare Source
Semaphore::const_newwasn't available on Tokio < 1.30 because of the missing Tokioparking_lotfeature flagfuturescrate (aside fromfutures-core)Thanks to @tottoto
v1.3.0Compare Source
Server::new_with_opts,Server::new_with_opts_asyncand theServerOptsstruct to allow configuring the server host, port and enabling auto-asserts (see next item)assert_on_dropserver option that allows you to automatically callassert()whenever your mocks go out of scope (defaults to false)Server::socket_address()to return the raw serverSocketAddrhyper::header::HeaderValueas amatch_header()valueThanks to @andrewtoth @alexander-jackson
v1.2.0Compare Source
mac_ostargets to prevent hitting the file descriptor limitThanks to @kornelski
v1.1.1Compare Source
with_chunked_bodysupports streaming responses (as opposed to writing the entire buffer in one go)Thanks to @kornelski
v1.1.0Compare Source
v1.0.2Compare Source
v1.0.1Compare Source
futures::future::join_allwould block the server pool.Server::reset_asynchas been deprecated in favour ofServer::resetsince the former doesn't have an async implementation any more.v1.0.0Compare Source
🎈 7 years and 63 releases later, it's finally time for the 1.0 🎈
Changes
Mock::with_body_from_fnwas renamed toMock::with_chunked_body- the former is still supported with a deprecation warningMock::removeandMock::remove_asyncmethods to remove mocks on demandMajor changes since 0.31
For a list of all the changes please check the release log.
Migrating to the new API
Legacy API:
New API:
Migrating to the async API
In order to write async tests, you'll need to use the
_asyncmethods:Server::new_asyncMock::create_asyncMock::assert_asyncMock::matched_asyncMock::remove_asyncServer::reset_async...otherwise your tests will not compile and you'll see this error:
Example:
v0.32.5Compare Source
Arc(more reliable in this case)v0.32.4Compare Source
Mock::with_body_from_requestwhich allows setting the response body dynamically, based on theRequestobjectMutexwith anRwLockv0.32.3Compare Source
Server::newandServer::new_asyncnow return aServerGuardobject which dereferences toServer- this is only relevant if you need to assign a type to your serverv0.32.2Compare Source
_asyncmethodsv0.32.1Compare Source
v0.32.0Compare Source
This is a major re-write, introducing a bunch of long awaited features:
[Breaking] The minimum supported Rust version was bumped to 1.65.0
Tests can now run in parallel as long as you use the new
mockito::ServerAPI:You can run multiple servers/hosts at the same time:
Support for HTTP2
An async interface for all actions (though the sync interface is also available):
The backend has been rewritten to use Hyper
This version will be backwards compatible with the previous version, but deprecation warnings have been introduced and you are encouraged to migrate, since the old API still requires running tests sequentially. Migrating to the new API is quite straighforward:
Migrating to the new API
Legacy API:
New API:
Migrating to the async API
In order to write async tests, you'll need to use the
_asyncmethods:Server::new_asyncMock::create_asyncMock::assert_asyncMock::matched_asyncServer::reset_async...otherwise your tests will not compile and you'll see this error:
Cannot start a runtime from within a runtime.When using tokio, prefer the single-threaded runtime over the multi-threaded one.
Example:
v0.31.1Compare Source
Thanks to @chantra
v0.31.0Compare Source
Thanks to @ameliabradley
v0.30.0Compare Source
assert-json-diffdependency.Thanks to @davidpdrsn
v0.29.0Compare Source
rand,colored,serde_urlencoded,env_loggerThanks to @kornelski and @davidpdrsn
v0.28.0Compare Source
Matcher::Binaryvariant for matching binary content.Thanks to @torrefatto
v0.27.0Compare Source
Mock#matched()as a soft way of checking that a Mock, as opposed to theMock#assert()method, which panics.Thanks @max-b
v0.26.0Compare Source
v0.25.3Compare Source
+wouldn't be interpreted properly byMatcher::UrlEncoded.Thanks to @cakekindel
v0.25.2Compare Source
AllOfandAnyOfparts.Thanks to @max-b
v0.25.1Compare Source
96f3e30v0.25.0Compare Source
b0966f8501 Mock Not Implementedresponse now comes with acontent-length: 0header, to prevent some clients from hanging.Thanks to @xneomac
v0.23.3Compare Source
assert-json-difflibrary (version 1.0.3)v0.23.2Compare Source
assert-json-difflibrary.Thanks to @vldm
v0.23.1Compare Source
connection: closeheader on all responses delivered by Mockito as this is the default behaviour at the moment.v0.23.0Compare Source
Mock#expect_at_leastandMock#expect_at_mostfunctions to be used together withMock#assert.cargo fmtformatting as part of CI.Thanks to @kornelski @xneomac @thomasetter
v0.22.0Compare Source
AnyOfmatcher for the path/query parts within amockcall.Thanks to @thomasetter
v0.21.0Compare Source
color(enabled by default), that controls whether the output is coloured and, more importantly, whether thecoloredcrate is required.Thanks to @repi
v0.20.0Compare Source
Matcher::PartialJsonandMatcher::PartialJsonStringvariants to match a JSON String partially (inclusion).Thanks to @matteosister
v0.19.0Compare Source
Mock#with_body_from_fnfunction, which allows generating the response body programmatically.Thanks to @kornelski
v0.18.0Compare Source
Matcher::AllOf, which can be used to check a set of matchers in conjunction. It works in a similar way to the existingMatcher::AnyOf.Matcher::UrlEncodedto match key/value pairs in URL-encoded strings.Mock#match_queryto be able to match the URL query part distinctly from the path. The function supports all known matchers but works best withMatcher::UrlEncoded. The old behaviour of matching the query as part of the path argument in amockcall has been preserved, but usingMock#match_queryhas the effect of overriding that.🎈 🎈 🎈
v0.17.1Compare Source
Thanks to @ignatenkobrain
v0.17.0Compare Source
Transfer-Encoding: chunked.Thanks to @loyd
v0.16.0Compare Source
Content-Length.Content-Lengthresponse header and skipping the response body entirely in the particular case ofHEADrequests.Thanks to @loyd
v0.15.1Compare Source
Thanks to @saks
v0.15.0Compare Source
mockito::SERVER_URLormockito::SERVER_ADDRESStomockito::server_url()ormockito::server_address().Thanks to @kornelski
v0.14.1Compare Source
v0.14.0Compare Source
~~This is the release candidate for the 1.0.0 🎉 ~~
Matcher::JSON, in favour ofMatcher::Json.Thanks to @sterlingjensen, @otavio, @galaxie and @mikrostew
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.