Skip to content

update mockito to 0.32.0 #1212

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

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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