Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
Signed-off-by: Koen de Laat <[email protected]>
  • Loading branch information
koendelaat committed Nov 5, 2024
1 parent 8e27a63 commit 68418be
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/apply_conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) fn apply(source_dir: &str) -> Result<(), anyhow::Error> {
source_dir,
STATIC_SYSTEM_CONNECTIONS_DIR,
)
.context("Copying connection files")?;
.context("Copying connection files")?;
}

disable_wired_connections(CONFIG_DIR, RUNTIME_SYSTEM_CONNECTIONS_DIR)
Expand Down Expand Up @@ -141,10 +141,10 @@ fn copy_unified_connection_files(

if entry.metadata()?.is_dir()
|| path
.extension()
.and_then(OsStr::to_str)
.unwrap_or_default()
.ne(CONNECTION_FILE_EXT)
.extension()
.and_then(OsStr::to_str)
.unwrap_or_default()
.ne(CONNECTION_FILE_EXT)
{
warn!("Ignoring unexpected entry: {path:?}");
continue;
Expand Down Expand Up @@ -186,7 +186,10 @@ fn copy_connection_files(
let connections = &interface.connection_ids;

if connections.is_empty() {
return Err(anyhow!("Missing connection ids for {}", &interface.logical_name));
return Err(anyhow!(
"Missing connection ids for {}",
&interface.logical_name
));
}

for connection in connections {
Expand Down Expand Up @@ -610,7 +613,8 @@ mod tests {
detected_interfaces.clone(),
source_dir,
destination_dir
).is_ok());
)
.is_ok());

let source_path = Path::new(source_dir).join("node1");
let destination_path = Path::new(destination_dir);
Expand Down Expand Up @@ -648,22 +652,18 @@ mod tests {

let host = Host {
hostname: "node1".to_string(),
interfaces: vec![
Interface {
logical_name: "eth0".to_string(),
mac_address: Option::from("00:11:22:33:44:55".to_string()),
interface_type: "ethernet".to_string(),
connection_ids: Vec::new(),
},
],
interfaces: vec![Interface {
logical_name: "eth0".to_string(),
mac_address: Option::from("00:11:22:33:44:55".to_string()),
interface_type: "ethernet".to_string(),
connection_ids: Vec::new(),
}],
};

assert!(copy_connection_files(
host,
HashMap::new(),
source_dir,
destination_dir
).is_err_and(|e| e.to_string().contains("Missing connection ids")));
assert!(
copy_connection_files(host, HashMap::new(), source_dir, destination_dir)
.is_err_and(|e| e.to_string().contains("Missing connection ids"))
);

// cleanup
fs::remove_dir_all(destination_dir)
Expand Down

0 comments on commit 68418be

Please sign in to comment.