diff --git a/sdk/iot_deviceupdate/Cargo.toml b/sdk/iot_deviceupdate/Cargo.toml index dd68f22147..a4002090ff 100644 --- a/sdk/iot_deviceupdate/Cargo.toml +++ b/sdk/iot_deviceupdate/Cargo.toml @@ -28,7 +28,7 @@ azure_identity = { path = "../identity", version="0.9", default_features = false [dev-dependencies] tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } -mockito = "0.31" +mockito = "0.32.2" async-trait = "0.1" [features] diff --git a/sdk/iot_deviceupdate/src/device_update.rs b/sdk/iot_deviceupdate/src/device_update.rs index 5a5abb62a5..b4f166956b 100644 --- a/sdk/iot_deviceupdate/src/device_update.rs +++ b/sdk/iot_deviceupdate/src/device_update.rs @@ -509,22 +509,25 @@ impl DeviceUpdateClient { #[cfg(test)] mod tests { use azure_core::date; - use mockito::{mock, Matcher}; + use mockito::{Matcher, Server}; use serde_json::json; use crate::{client::API_VERSION, tests::mock_client}; #[tokio::test] async fn can_import_update() -> azure_core::Result<()> { - let _m = mock("POST", "/deviceupdate/test-instance/updates") + let mut server = Server::new_async().await; + let _m = server + .mock("POST", "/deviceupdate/test-instance/updates") .match_query(Matcher::UrlEncoded( "api-version".into(), API_VERSION.into(), )) .with_header("operation-location", "/op_location") .with_status(202) - .create(); - let _op = mock("GET", "/op_location") + .create_async() + .await; + let _op = server.mock("GET", "/op_location") .with_header("content-type", "application/json") .with_body( json!({ @@ -544,9 +547,9 @@ mod tests { .to_string(), ) .with_status(200) - .create(); + .create_async().await; - let client = mock_client(); + let client = mock_client(server.url()); let update = client .import_update( diff --git a/sdk/iot_deviceupdate/src/lib.rs b/sdk/iot_deviceupdate/src/lib.rs index 81d3ae8899..9a32990ca1 100644 --- a/sdk/iot_deviceupdate/src/lib.rs +++ b/sdk/iot_deviceupdate/src/lib.rs @@ -14,9 +14,9 @@ mod tests { use std::sync::Arc; use time::OffsetDateTime; - pub(crate) fn mock_client() -> crate::client::DeviceUpdateClient { + pub(crate) fn mock_client(server_url: String) -> crate::client::DeviceUpdateClient { crate::client::DeviceUpdateClient { - device_update_url: url::Url::parse(&mockito::server_url()).unwrap(), + device_update_url: url::Url::parse(&server_url).unwrap(), endpoint: "".to_string(), token_credential: AutoRefreshingTokenCredential::new(Arc::new(MockCredential)), } diff --git a/sdk/security_keyvault/Cargo.toml b/sdk/security_keyvault/Cargo.toml index ae425e9432..5c20821c14 100644 --- a/sdk/security_keyvault/Cargo.toml +++ b/sdk/security_keyvault/Cargo.toml @@ -26,7 +26,6 @@ azure_core = { path = "../core", version = "0.8", default-features = false } [dev-dependencies] azure_identity = { path = "../identity", default-features = false } -mockito = "0.31" async-trait = "0.1" tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }