Skip to content

Commit a3b70c4

Browse files
Copilotjosecelano
andcommitted
fix: [#116] address clippy linting errors
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
1 parent 7432591 commit a3b70c4

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

packages/dependency-installer/tests/containers/helpers.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ pub fn copy_file_to_container(container_id: &str, source_path: &Path, dest_path:
2525
let output = Command::new("docker")
2626
.arg("cp")
2727
.arg(source_path)
28-
.arg(format!("{}:{}", container_id, dest_path))
28+
.arg(format!("{container_id}:{dest_path}"))
2929
.output()
3030
.expect("Failed to execute docker cp command");
3131

3232
if !output.status.success() {
33-
panic!(
34-
"Failed to copy file to container: {}",
35-
String::from_utf8_lossy(&output.stderr)
36-
);
33+
let stderr = String::from_utf8_lossy(&output.stderr);
34+
panic!("Failed to copy file to container: {stderr}");
3735
}
3836
}
3937

@@ -65,7 +63,7 @@ pub fn exec_in_container(container_id: &str, command: &[&str]) -> String {
6563
// Combine stderr (logs) and stdout (user messages) to capture all output
6664
let stdout = String::from_utf8_lossy(&output.stdout);
6765
let stderr = String::from_utf8_lossy(&output.stderr);
68-
format!("{}{}", stderr, stdout)
66+
format!("{stderr}{stdout}")
6967
}
7068

7169
/// Execute a command in a container and return exit code
@@ -81,7 +79,7 @@ pub fn exec_in_container(container_id: &str, command: &[&str]) -> String {
8179
///
8280
/// # Note
8381
///
84-
/// If the process was terminated by a signal (returns None from code()), we return 1
82+
/// If the process was terminated by a signal (returns None from `code()`), we return 1
8583
/// to indicate failure rather than 0, which would incorrectly suggest success.
8684
pub fn exec_in_container_with_exit_code(container_id: &str, command: &[&str]) -> i32 {
8785
let status = Command::new("docker")

packages/dependency-installer/tests/containers/ubuntu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl UbuntuContainerBuilder {
6464
/// # Returns
6565
///
6666
/// A builder that can start the container with the binary
67+
#[allow(clippy::unused_self)]
6768
pub fn with_binary(self, binary_path: &Path) -> UbuntuContainerWithBinary {
6869
UbuntuContainerWithBinary {
6970
binary_path: binary_path.to_path_buf(),

packages/dependency-installer/tests/docker_check_command.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,19 @@ async fn test_check_all_reports_missing_dependencies() {
2727
// Verify it reports missing dependencies
2828
assert!(
2929
output.contains("cargo-machete: not installed"),
30-
"Expected cargo-machete to be reported as not installed, got: {}",
31-
output
30+
"Expected cargo-machete to be reported as not installed, got: {output}"
3231
);
3332
assert!(
3433
output.contains("OpenTofu: not installed"),
35-
"Expected OpenTofu to be reported as not installed, got: {}",
36-
output
34+
"Expected OpenTofu to be reported as not installed, got: {output}"
3735
);
3836
assert!(
3937
output.contains("Ansible: not installed"),
40-
"Expected Ansible to be reported as not installed, got: {}",
41-
output
38+
"Expected Ansible to be reported as not installed, got: {output}"
4239
);
4340
assert!(
4441
output.contains("LXD: not installed"),
45-
"Expected LXD to be reported as not installed, got: {}",
46-
output
42+
"Expected LXD to be reported as not installed, got: {output}"
4743
);
4844

4945
// Verify exit code is non-zero (failure)
@@ -72,8 +68,7 @@ async fn test_check_specific_tool() {
7268
// in all terminal environments or when output is redirected
7369
assert!(
7470
output.contains("OpenTofu: not installed"),
75-
"Expected OpenTofu to be reported as not installed, got: {}",
76-
output
71+
"Expected OpenTofu to be reported as not installed, got: {output}"
7772
);
7873

7974
let exit_code =
@@ -99,30 +94,25 @@ async fn test_list_command() {
9994
// Verify all tools are listed
10095
assert!(
10196
output.contains("cargo-machete"),
102-
"Expected cargo-machete to be listed, got: {}",
103-
output
97+
"Expected cargo-machete to be listed, got: {output}"
10498
);
10599
assert!(
106100
output.contains("OpenTofu"),
107-
"Expected OpenTofu to be listed, got: {}",
108-
output
101+
"Expected OpenTofu to be listed, got: {output}"
109102
);
110103
assert!(
111104
output.contains("Ansible"),
112-
"Expected Ansible to be listed, got: {}",
113-
output
105+
"Expected Ansible to be listed, got: {output}"
114106
);
115107
assert!(
116108
output.contains("LXD"),
117-
"Expected LXD to be listed, got: {}",
118-
output
109+
"Expected LXD to be listed, got: {output}"
119110
);
120111

121112
// Verify status is shown
122113
assert!(
123114
output.contains("not installed"),
124-
"Expected 'not installed' status to be shown, got: {}",
125-
output
115+
"Expected 'not installed' status to be shown, got: {output}"
126116
);
127117
}
128118

@@ -142,8 +132,7 @@ async fn test_verbose_output() {
142132
// The CLI uses tracing, so we should see timestamp-prefixed log messages
143133
assert!(
144134
output.contains("INFO") || output.contains("Checking"),
145-
"Expected verbose output to contain INFO logs or 'Checking' message, got: {}",
146-
output
135+
"Expected verbose output to contain INFO logs or 'Checking' message, got: {output}"
147136
);
148137
}
149138

@@ -154,15 +143,15 @@ async fn test_verbose_output() {
154143
///
155144
/// # Implementation Note
156145
///
157-
/// We use CARGO_MANIFEST_DIR and navigate up to the workspace root, then into
146+
/// We use `CARGO_MANIFEST_DIR` and navigate up to the workspace root, then into
158147
/// the target directory. This works because:
159-
/// 1. CARGO_MANIFEST_DIR points to packages/dependency-installer
148+
/// 1. `CARGO_MANIFEST_DIR` points to packages/dependency-installer
160149
/// 2. The workspace root is two directories up
161150
/// 3. The target directory is in the workspace root
162151
///
163152
/// Alternative approaches considered:
164-
/// - CARGO_TARGET_DIR: Not always set
165-
/// - OUT_DIR: Points to build script output, not target/debug
153+
/// - `CARGO_TARGET_DIR`: Not always set
154+
/// - `OUT_DIR`: Points to build script output, not target/debug
166155
/// - Searching for target dir: Too expensive
167156
fn get_binary_path() -> PathBuf {
168157
// Get the package manifest directory (packages/dependency-installer)
@@ -182,8 +171,8 @@ fn get_binary_path() -> PathBuf {
182171

183172
assert!(
184173
path.exists(),
185-
"Binary not found at {:?}. Run 'cargo build --bin dependency-installer' first",
186-
path
174+
"Binary not found at {}. Run 'cargo build --bin dependency-installer' first",
175+
path.display()
187176
);
188177

189178
path

0 commit comments

Comments
 (0)