Skip to content

Commit

Permalink
chore: cleanup all compiler warnings when features are turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jun 17, 2024
1 parent 0ac8911 commit ec7e68f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pact_mock_server/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Provides a builder for constructing mock servers

use anyhow::anyhow;
#[allow(unused_imports)] use anyhow::anyhow;
use pact_models::pact::Pact;
use pact_models::PactSpecification;
use pact_models::v4::pact::V4Pact;
Expand Down
4 changes: 2 additions & 2 deletions pact_mock_server/src/hyper_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::collections::HashMap;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::net::SocketAddr;
use std::sync::Arc;
#[cfg(feature = "tls")] use std::sync::Arc;

use anyhow::anyhow;
#[allow(unused_imports)] use anyhow::anyhow;
use bytes::Bytes;
use http_body_util::{BodyExt, Full};
use hyper::{Request, Response};
Expand Down
24 changes: 10 additions & 14 deletions pact_mock_server/src/legacy/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
//! Deprecated 1.x mock server functions

use std::path::PathBuf;

use anyhow::anyhow;
use itertools::{Either, Itertools};
use pact_models::pact::{load_pact_from_json, Pact, ReadWritePact, write_pact};
use pact_models::PactSpecification;
use itertools::Either;
use pact_models::pact::{load_pact_from_json, Pact};
#[cfg(feature = "plugins")] use pact_plugin_driver::catalogue_manager;
#[cfg(feature = "plugins")] use pact_plugin_driver::plugin_manager::get_mock_server_results;
#[cfg(feature = "tls")] use rustls::ServerConfig;
use serde_json::json;
use tracing::{error, info, warn};
#[allow(unused_imports)] use tracing::{error, info, warn};
use uuid::Uuid;

use crate::{configure_core_catalogue, MANAGER, MockServerError, WritePactFileErr};
Expand Down Expand Up @@ -162,7 +158,7 @@ pub fn start_mock_server_for_transport(

let key = format!("transport/{}", transport);
let transport_entry = catalogue_manager::lookup_entry(key.as_str())
.ok_or_else(|| anyhow!("Transport '{}' is not a known transport", transport))?;
.ok_or_else(|| anyhow::anyhow!("Transport '{}' is not a known transport", transport))?;

#[allow(deprecated)]
MANAGER.lock().unwrap()
Expand Down Expand Up @@ -305,9 +301,9 @@ pub fn mock_server_mismatches(mock_server_port: i32) -> Option<String> {
"path": mismatch.path,
"diff": mismatch.diff.clone().unwrap_or_default()
})
}).collect_vec()
}).collect::<Vec<_>>()
})
}).collect_vec())
}).collect::<Vec<_>>())
},
Err(err) => {
error!("Request to plugin to get matching results failed - {}", err);
Expand Down Expand Up @@ -356,18 +352,18 @@ pub fn write_pact_file(
{
let mut pact = _plugin_mock_server.pact.clone();
pact.add_md_version("mockserver", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"));
let pact_file_name = pact.default_file_name();
let pact_file_name = pact_models::pact::ReadWritePact::default_file_name(&pact);
let filename = match directory {
Some(ref path) => {
let mut path = PathBuf::from(path);
let mut path = std::path::PathBuf::from(path);
path.push(pact_file_name);
path
},
None => PathBuf::from(pact_file_name)
None => std::path::PathBuf::from(pact_file_name)
};

info!("Writing pact out to '{}'", filename.display());
match write_pact(pact.boxed(), filename.as_path(), PactSpecification::V4, overwrite) {
match pact_models::pact::write_pact(pact.boxed(), filename.as_path(), pact_models::PactSpecification::V4, overwrite) {
Ok(_) => Ok(()),
Err(err) => {
warn!("Failed to write pact to file - {}", err);
Expand Down
9 changes: 6 additions & 3 deletions pact_mock_server/src/mock_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ impl MockServerConfig {
// Need to implement this, as we can't compare TLS configuration.
impl PartialEq for MockServerConfig {
fn eq(&self, other: &Self) -> bool {
let mut ok = self.cors_preflight == other.cors_preflight
let ok = self.cors_preflight == other.cors_preflight
&& self.pact_specification == other.pact_specification
&& self.transport_config == other.transport_config
&& self.address == other.address
&& self.mockserver_id == other.mockserver_id;

#[cfg(feature = "plugins")]
{
ok = ok && self.transport_entry == other.transport_entry;
ok && self.transport_entry == other.transport_entry
}

ok
#[cfg(not(feature = "plugins"))]
{
ok
}
}
}

Expand Down
1 change: 1 addition & 0 deletions pact_mock_server/src/server_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ impl ServerManager {
}
#[cfg(not(feature = "plugins"))]
{
#[allow(unused_imports)]
self.start_mock_server_with_addr(id, pact, addr, config)
.map_err(|err| anyhow!(err))
}
Expand Down

0 comments on commit ec7e68f

Please sign in to comment.