Skip to content

Commit

Permalink
Update mockito requirement from 0.31 to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Aug 8, 2023
1 parent de68226 commit 5e39b7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
12 changes: 7 additions & 5 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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);

Expand All @@ -39,16 +39,18 @@ 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")
.with_status(status.parse().unwrap())
.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)
}
2 changes: 1 addition & 1 deletion tests/errors_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 5e39b7d

Please sign in to comment.