Skip to content

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Jun 18, 2022

This PR contains the following updates:

Package Type Update Change
mockito dev-dependencies minor 0.30.0 -> 0.32.0

Release Notes

lipanski/mockito (mockito)

v0.32.5

Compare Source

  • Implement and enable a new server pool and get rid of the deadpool dependency
  • Replace the mpsc mock/server communication with Arc (more reliable in this case)
  • Split sync & async paths more clearly

v0.32.4

Compare Source

  • Introduce Mock::with_body_from_request which allows setting the response body dynamically, based on the Request object
  • Small performance improvement: replace the state Mutex with an RwLock
  • Small fixes to the documentation (thanks @​konstin)

v0.32.3

Compare Source

  • Various fixes addressing hanging/flickering tests
  • Server::new and Server::new_async now return a ServerGuard object which dereferences to Server - this is only relevant if you need to assign a type to your server
  • The server pool has been disabled and will be brought back in a future release

v0.32.2

Compare Source

  • Prevent the Mock destructor from hanging in some cases
  • Updates to the docs, clarifying the usage of _async methods

v0.32.1

Compare Source

v0.32.0

Compare 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::Server API:

    let mut server = mockito::Server::new();
    let mock = server.mock("GET", "/").with_body("test").create();
    
    // Use one of these to configure your client
    let host = server.host_with_port();
    let url = server.url();
  • You can run multiple servers/hosts at the same time:

    let mut twitter = mockito::Server::new();
    let twitter_mock = server.mock("GET", "/api").with_body("tweet").create();
    let twitter_host = twitter.host_with_port();
    
    let mut github = mockito::Server::new();
    let github_mock = server.mock("GET", "/api").with_body("repo").create();
    let github_host = github.host_with_port();
  • Support for HTTP2

  • An async interface for all actions (though the sync interface is also available):

    let mut server = Server::new_async().await;
    let mock = s
        .mock("GET", "/hello")
        .with_body("world")
        .create_async()
        .await;
    
    mock.assert_async().await;
  • 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:

let m = mockito::mock("GET", "/").with_body("hello").create();

// Use one of these to configure your client
let host = mockito:server_address();
let url = mockito::server_url();

New API:

let mut server = mockito::Server::new();
let m = sever.mock("GET", "/").with_body("hello").create();

// Use one of these to configure your client
let host = server.host_with_port();
let url = server.url();

Migrating to the async API

In order to write async tests, you'll need to use the _async methods:

  • Server::new_async
  • Mock::create_async
  • Mock::assert_async
  • Mock::matched_async
  • Server::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:

#[tokio::test]
async fn test_simple_route_mock_async() {
    let mut server = Server::new_async().await;
    let m1 = server.mock("GET", "/a").with_body("aaa").create_async().await;
    let m2 = server.mock("GET", "/b").with_body("bbb").create_async().await;

    let (m1, m2) = futures::join!(m1, m2);

    // You can use `Mock::assert_async` to verify that your mock was called
    // m1.assert_async().await;
    // m2.assert_async().await;
}

v0.31.1

Compare Source

  • Prevent tests from blocking endlessly when encountering HTTP parsing errors.

Thanks to @​chantra

v0.31.0

Compare Source

  • Replaced the unmaintained difference crate with the similar crate.

Thanks to @​ameliabradley


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/mockito-0.x branch from 331e676 to 7d43666 Compare September 25, 2022 12:59
@renovate renovate bot force-pushed the renovate/mockito-0.x branch from 7d43666 to a3ab168 Compare November 20, 2022 09:32
@renovate renovate bot force-pushed the renovate/mockito-0.x branch from a3ab168 to bb6d140 Compare March 18, 2023 06:03
@renovate renovate bot changed the title chore(deps): update rust crate mockito to 0.31.0 chore(deps): update rust crate mockito to 0.32.5 Mar 18, 2023
@renovate renovate bot force-pushed the renovate/mockito-0.x branch from bb6d140 to 05e1650 Compare May 5, 2024 10:52
@renovate renovate bot changed the title chore(deps): update rust crate mockito to 0.32.5 chore(deps): update rust crate mockito to 0.32.0 May 5, 2024
@renovate renovate bot force-pushed the renovate/mockito-0.x branch from 05e1650 to 592f9f0 Compare September 11, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants