Skip to content

Commit

Permalink
update mockito to 0.32.0 (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
demoray authored Feb 15, 2023
1 parent c8697a6 commit 7cfc112
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sdk/iot_deviceupdate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 9 additions & 6 deletions sdk/iot_deviceupdate/src/device_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!({
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions sdk/iot_deviceupdate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
Expand Down
1 change: 0 additions & 1 deletion sdk/security_keyvault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down

0 comments on commit 7cfc112

Please sign in to comment.