Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update rust crate mockito to v1 (1.x) #12272

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jan 6, 2025

This PR contains the following updates:

Package Type Update Change
mockito dev-dependencies major 0.31 -> 1.0

Release Notes

lipanski/mockito (mockito)

v1.6.1

Compare Source

  • Added Mock::with_header_from_request allowing you to set the header dynamically by using a closure which exposes the Request object

Thanks to @​alex-kattathra-johnson

v1.6.0

Compare Source

  • Introduced Mock::match_request which exposes the Request object via a closure and can be used to build custom matchers

v1.5.0

Compare Source

Thanks to @​tottoto

v1.4.0

Compare Source

  • [Breaking] Bump minimum supported Rust version to 1.70 and revert version constraints on the colored crate

v1.3.1

Compare Source

  • Fixed a bug where Semaphore::const_new wasn't available on Tokio < 1.30 because of the missing Tokio parking_lot feature flag
  • Use the Tokio runtime everywhere to remove the need for the futures crate (aside from futures-core)

Thanks to @​tottoto

v1.3.0

Compare Source

  • Introduced Server::new_with_opts, Server::new_with_opts_async and the ServerOpts struct to allow configuring the server host, port and enabling auto-asserts (see next item)
  • Added the assert_on_drop server option that allows you to automatically call assert() whenever your mocks go out of scope (defaults to false)
  • Expose Server::socket_address() to return the raw server SocketAddr
  • Use only required features for dependencies
  • Accept hyper::header::HeaderValue as a match_header() value

Thanks to @​andrewtoth @​alexander-jackson

v1.2.0

Compare Source

  • [Breaking] The minimum supported Rust version was bumped to 1.68.0
  • The server pool was limited to 20 servers for mac_os targets to prevent hitting the file descriptor limit

Thanks to @​kornelski

v1.1.1

Compare Source

  • Ensure with_chunked_body supports streaming responses (as opposed to writing the entire buffer in one go)

Thanks to @​kornelski

v1.1.0

Compare Source

v1.0.2

Compare Source

v1.0.1

Compare Source

  • Fixed an issue where futures::future::join_all would block the server pool.
  • Server::reset_async has been deprecated in favour of Server::reset since the former doesn't have an async implementation any more.

v1.0.0

Compare Source

🎈 7 years and 63 releases later, it's finally time for the 1.0 🎈

Changes

  • [Breaking] The legacy interface was removed in this version
  • [Breaking] Mock::with_body_from_fn was renamed to Mock::with_chunked_body - the former is still supported with a deprecation warning
  • Mocks are only cleared when the server is dropped, not when the mock is dropped - this means you don't have to assign mocks to variables any more (unless you want to call other methods on them)
  • Introduced the Mock::remove and Mock::remove_async methods to remove mocks on demand

Major changes since 0.31

  • Tests can now run in parallel
  • Support for HTTP2
  • An async interface for all actions (though the sync interface is also available)
  • Mock multiple server/hosts at the same time

For a list of all the changes please check the release log.

Migrating to the new API

Legacy API:

let m1 = mockito::mock("GET", "/hello").with_body("hello").create();
let m2 = mockito::mock("GET", "/bye").with_body("bye").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();
server.mock("GET", "/hello").with_body("hello").create();
server.mock("GET", "/bye").with_body("bye").create();

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

If you can't migrate to the new API in one go, consider using version 0.32.5, which supports both the legacy API as well as the new API.

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
  • Mock::remove_async
  • Server::reset_async

...otherwise your tests will not compile and you'll see this error:

Cannot block the current thread from within a runtime. This happens because a function attempted 
to block the current thread while the thread is being used to drive asynchronous tasks.

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.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;
}

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 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 requested a review from a team as a code owner January 6, 2025 12:14
@renovate renovate bot added the type: chore label Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

Package Changes Through 9925da5

There are 1 changes which include tauri-utils with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 1.6.1 1.6.2
tauri-bundler 1.7.2 1.7.3
tauri-runtime 0.14.5 0.14.6
tauri-runtime-wry 0.14.10 0.14.11
tauri-codegen 1.4.5 1.4.6
tauri-macros 1.4.6 1.4.7
tauri-build 1.5.5 1.5.6
tauri 1.8.1 1.8.2
@tauri-apps/cli 1.6.4 1.6.5
tauri-cli 1.6.4 1.6.5

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@FabianLars FabianLars closed this Jan 6, 2025
@FabianLars FabianLars deleted the renovate/1.x-mockito-1.x branch January 6, 2025 12:34
Copy link
Contributor Author

renovate bot commented Jan 6, 2025

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 1.x releases. But if you manually upgrade to 1.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant