Skip to content

Commit 78e1412

Browse files
Adwait DeshpandeAdwait Deshpande
authored andcommitted
CI/test fixes: update tests, lints, and small refactors
1 parent e66d517 commit 78e1412

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/report.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use humansize::{format_size, DECIMAL};
44
use ignore::WalkBuilder;
55
use std::collections::HashMap;
66
use std::fs;
7-
use std::path::PathBuf;
7+
use std::path::{Path, PathBuf};
88

99
pub fn run_report(path: Option<PathBuf>, recipes_path: Option<PathBuf>, output: Option<PathBuf>) -> Result<()> {
1010
let root = path.unwrap_or(std::env::current_dir()?);
@@ -13,7 +13,7 @@ pub fn run_report(path: Option<PathBuf>, recipes_path: Option<PathBuf>, output:
1313
let out = output.unwrap_or_else(|| PathBuf::from("report.md"));
1414

1515
let mut lines: Vec<String> = Vec::new();
16-
lines.push(format!("# DevSpace Sweeper Report"));
16+
lines.push("# DevSpace Sweeper Report".to_string());
1717
lines.push(format!("Root: {}\n", root.display()));
1818
let mut total = 0u64;
1919

@@ -34,7 +34,8 @@ pub fn run_report(path: Option<PathBuf>, recipes_path: Option<PathBuf>, output:
3434
Ok(())
3535
}
3636

37-
pub fn compute_ignore_hints(root: &PathBuf, patterns: &[&str]) -> HashMap<String, usize> {
37+
#[allow(dead_code)]
38+
pub fn compute_ignore_hints(_root: &Path, patterns: &[&str]) -> HashMap<String, usize> {
3839
let mut hints: HashMap<String, usize> = HashMap::new();
3940
for p in patterns {
4041
*hints.entry((*p).to_string()).or_insert(0) += 1;

src/scan.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::fs;
77
use std::io::Write;
88
use std::path::{Path, PathBuf};
99

10+
#[allow(dead_code)]
1011
#[derive(Debug, Clone)]
1112
pub struct MatchInfo {
1213
pub path: PathBuf,
@@ -96,7 +97,8 @@ pub fn run_gen_ignore(path: Option<PathBuf>, recipes_path: Option<PathBuf>, dry_
9697
fs::OpenOptions::new().append(true).open(&gi_path)
9798
.with_context(|| format!("Failed to open {}", gi_path.display()))?
9899
} else {
99-
fs::OpenOptions::new().create(true).write(true).open(&gi_path)
100+
// Explicitly set truncate(false) so behavior is clear to clippy/lints
101+
fs::OpenOptions::new().create(true).write(true).truncate(false).open(&gi_path)
100102
.with_context(|| format!("Failed to create {}", gi_path.display()))?
101103
};
102104
writeln!(file, "\n# Added by devspace-sweeper")?;

tests/integration.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use assert_cmd::Command;
2+
use assert_cmd::cargo::cargo_bin_cmd;
23
use predicates::prelude::*;
34
use std::fs;
45
use std::path::PathBuf;
@@ -20,7 +21,7 @@ fn create_fixture() -> (TempDir, PathBuf) {
2021
#[test]
2122
fn scan_should_list_groups() {
2223
let (_td, root) = create_fixture();
23-
let mut cmd = Command::cargo_bin("devspace-sweeper").unwrap();
24+
let mut cmd = cargo_bin_cmd!("devspace-sweeper");
2425
cmd.arg("scan").arg("--path").arg(root);
2526
cmd.assert()
2627
.success()
@@ -32,7 +33,7 @@ fn scan_should_list_groups() {
3233
#[test]
3334
fn suggest_should_print_hints_and_safety() {
3435
let (_td, root) = create_fixture();
35-
let mut cmd = Command::cargo_bin("devspace-sweeper").unwrap();
36+
let mut cmd = cargo_bin_cmd!("devspace-sweeper");
3637
cmd.arg("suggest").arg("--path").arg(root);
3738
cmd.assert()
3839
.success()
@@ -43,7 +44,7 @@ fn suggest_should_print_hints_and_safety() {
4344
#[test]
4445
fn gen_ignore_dry_run_should_output_patterns() {
4546
let (_td, root) = create_fixture();
46-
let mut cmd = Command::cargo_bin("devspace-sweeper").unwrap();
47+
let mut cmd = cargo_bin_cmd!("devspace-sweeper");
4748
cmd.arg("gen-ignore").arg("--path").arg(&root).arg("--dry-run").arg("true");
4849
cmd.assert()
4950
.success()

0 commit comments

Comments
 (0)