diff --git a/Cargo.toml b/Cargo.toml index 7aac7a4..d0e7344 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "amp-client" description = "The Amphitheatre API client for Rust" -version = "0.2.8" +version = "0.2.9" edition = "2021" license = "Apache-2.0" homepage = "https://amphitheatre.app" @@ -16,5 +16,5 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["raw_value"] } [dev-dependencies] -mockito = "0.31" +mockito = "1.1.0" assert_matches = "1.5" diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 7f0e287..a6d51c4 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -17,7 +17,7 @@ use std::fs; use amp_client::client::Client; -use mockito::{mock, Mock}; +use mockito::{Server, ServerGuard}; /// Creates a mockserver and a client (changing the url of the client /// to that of the mockserver to capture the requests). @@ -29,7 +29,7 @@ use mockito::{mock, Mock}; /// `fixture`: the path to the fixture inside the `api` directory /// `path`: the path in the server (i.e. `/me`) /// `method`: the HTTP method we are going to use (GET, POST, DELETE, ...) -pub fn setup_mock_for(path: &str, fixture: &str, method: &str) -> (Client, Mock) { +pub fn setup_mock_for(path: &str, fixture: &str, method: &str) -> (Client, ServerGuard) { let path = format!("/v1{}", path); let fixture = format!("./tests/fixtures/v1/api/{}.http", fixture); @@ -39,7 +39,9 @@ pub fn setup_mock_for(path: &str, fixture: &str, method: &str) -> (Client, Mock) let status = &content[9..12]; let body = lines.last(); - let mock = mock(method, path.as_str()) + let mut server = Server::new(); + server + .mock(method, path.as_str()) .with_header("x-ratelimit-limit", "2") .with_header("x-ratelimit-remaining", "2") .with_header("x-ratelimit-after", "never") @@ -47,8 +49,8 @@ pub fn setup_mock_for(path: &str, fixture: &str, method: &str) -> (Client, Mock) .with_body(body.unwrap()) .create(); - let base_url = format!("{}/v1", mockito::server_url()); + let base_url = format!("{}/v1", server.url()); let client = Client::new(&base_url, Some("some-token".to_string())); - (client, mock) + (client, server) } diff --git a/tests/errors_tests.rs b/tests/errors_tests.rs index 1de93b1..841e59d 100644 --- a/tests/errors_tests.rs +++ b/tests/errors_tests.rs @@ -75,5 +75,5 @@ fn transport() { let response = client.accounts().me(); let error = response.unwrap_err(); - assert_eq!("Transport Error - 501(Mock Not Found)", error.to_string()); + assert_eq!("Transport Error - 501(Not Implemented)", error.to_string()); }