Skip to content

Commit

Permalink
chore: allow dead code on unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Sep 19, 2023
1 parent 0909465 commit 097c990
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/gen/string.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

use rand::Rng;

pub struct StringRndGenerator;
Expand Down
5 changes: 5 additions & 0 deletions lib/src/wiremock_rs/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl Mock {
/// ```
///
/// [`matchers`]: crate::matchers
#[allow(dead_code)]
pub fn up_to_n_times(mut self, n: u64) -> Mock {
assert!(n > 0, "n must be strictly greater than 0!");
self.max_n_matches = Some(n);
Expand Down Expand Up @@ -386,6 +387,7 @@ impl Mock {
/// ```
///
/// [`matchers`]: crate::matchers
#[allow(dead_code)]
pub fn with_priority(mut self, p: u8) -> Mock {
assert!(p > 0, "priority must be strictly greater than 0!");
self.priority = p;
Expand Down Expand Up @@ -507,6 +509,7 @@ impl Mock {
/// // is not satisfied and the test will panic.
/// }
/// ```
#[allow(dead_code)]
pub fn named<T: Into<String>>(mut self, mock_name: T) -> Self {
self.name = Some(mock_name.into());
self
Expand All @@ -521,6 +524,7 @@ impl Mock {
///
/// [`register`]: MockServer::register
/// [`mount`]: Mock::mount
#[allow(dead_code)]
pub async fn mount(self, server: &MockServer) {
server.register(self).await;
}
Expand Down Expand Up @@ -621,6 +625,7 @@ impl Mock {
/// ```
///
/// [`mount`]: Mock::mount
#[allow(dead_code)]
pub async fn mount_as_scoped(self, server: &MockServer) -> MockGuard {
server.register_as_scoped(self).await
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/wiremock_rs/mock_server/bare_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl BareMockServer {
/// When using `register_as_scoped`, your `Mock`s will be active as long as the returned `MockGuard` is not dropped.
/// When the returned `MockGuard` is dropped, `MockServer` will verify that the expectations set on the scoped `Mock` were
/// verified - if not, it will panic.
#[allow(dead_code)]
pub async fn register_as_scoped(&self, mock: Mock) -> MockGuard {
let mock_id = self.state.write().await.mock_set.register(mock);
MockGuard {
Expand All @@ -108,6 +109,7 @@ impl BareMockServer {
///
/// It *must* be called if you plan to reuse a `BareMockServer` instance (i.e. in our
/// `MockServerPoolManager`).
#[allow(dead_code)]
pub(crate) async fn reset(&self) {
let mut state = self.state.write().await;
state.mock_set.reset();
Expand All @@ -134,6 +136,7 @@ impl BareMockServer {
/// Return the socket address of this running instance of `BareMockServer`, e.g. `127.0.0.1:4372`.
///
/// Use this method to interact with the `BareMockServer` using `TcpStream`s.
#[allow(dead_code)]
pub(crate) fn address(&self) -> &SocketAddr {
&self.server_address
}
Expand Down Expand Up @@ -180,6 +183,7 @@ pub struct MockGuard {
}

impl MockGuard {
#[allow(dead_code)]
pub async fn received_requests(&self) -> Vec<crate::wiremock_rs::Request> {
let state = self.server_state.read().await;
let (mounted_mock, _) = &state.mock_set[self.mock_id];
Expand Down
4 changes: 4 additions & 0 deletions lib/src/wiremock_rs/mock_server/exposed_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ impl MockServer {
/// assert_eq!(status, 404);
/// }
/// ```
#[allow(dead_code)]
pub async fn register_as_scoped(&self, mock: Mock) -> MockGuard {
self.0.register_as_scoped(mock).await
}
Expand Down Expand Up @@ -273,6 +274,7 @@ impl MockServer {
/// assert!(received_requests.is_empty())
/// }
/// ```
#[allow(dead_code)]
pub async fn reset(&self) {
self.0.reset().await;
}
Expand Down Expand Up @@ -357,6 +359,7 @@ impl MockServer {
/// ```
///
/// [`TcpStream`]: std::net::TcpStream
#[allow(dead_code)]
pub fn address(&self) -> &SocketAddr {
self.0.address()
}
Expand Down Expand Up @@ -423,6 +426,7 @@ impl MockServer {
/// assert!(received_requests.is_none());
/// }
/// ```
#[allow(dead_code)]
pub async fn received_requests(&self) -> Option<Vec<Request>> {
self.0.received_requests().await
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/wiremock_rs/mock_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl MountedMockSet {
}
}

#[allow(dead_code)]
pub(crate) fn reset(&mut self) {
self.mocks = vec![];
self.generation += 1;
Expand Down
1 change: 1 addition & 0 deletions lib/src/wiremock_rs/mounted_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl MountedMock {
self.specification.response_template(request)
}

#[allow(dead_code)]
pub(crate) fn received_requests(&self) -> Vec<Request> {
self.matched_requests.clone()
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/wiremock_rs/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ impl fmt::Display for Request {
}

impl Request {
#[allow(dead_code)]
pub fn body_json<T: DeserializeOwned>(&self) -> Result<T, serde_json::Error> {
serde_json::from_slice(&self.body)
}

#[allow(dead_code)]
pub async fn from(mut request: http_types::Request) -> Request {
let method = request.method();
let url = request.url().to_owned();
Expand Down
1 change: 1 addition & 0 deletions lib/src/wiremock_rs/response_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl ResponseTemplate {
/// assert_eq!(res.content_type(), Some(mime::JSON));
/// }
/// ```
#[allow(dead_code)]
pub fn set_body_raw<B>(mut self, body: B, mime: &str) -> Self
where
B: TryInto<Vec<u8>>,
Expand Down

0 comments on commit 097c990

Please sign in to comment.