Skip to content

Commit

Permalink
Fix clippy lints in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Feb 11, 2024
1 parent 64da7e3 commit 6a2673e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: --all-targets -- -D warnings
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mod tests {

let cleaned_projects = cleanup(&mocked_deps, &mut registry).unwrap();
assert_eq!(cleaned_projects.len(), 1);
assert_eq!(cleaned_projects.get(0).unwrap().0, String::from("app3"));
assert_eq!(cleaned_projects.first().unwrap().0, String::from("app3"));
}

#[test]
Expand Down
12 changes: 4 additions & 8 deletions src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ use unimock::{matching, Clause, MockFn, Unimock};
pub fn args_mock(args: &str) -> impl Clause {
ArgsMock
.each_call(matching!())
.returns(
args.split(' ')
.map(|arg| String::from(arg))
.collect::<Vec<_>>(),
)
.returns(args.split(' ').map(String::from).collect::<Vec<_>>())
.n_times(1)
}

Expand All @@ -28,17 +24,17 @@ pub fn choose_port_mock() -> impl Clause {
}

pub fn cwd_mock(project: &str) -> impl Clause {
let path = PathBuf::from(format!("/projects/{}", project));
let path = PathBuf::from(format!("/projects/{project}"));
WorkingDirectoryMock
.each_call(matching!())
.answers(move |_| Ok(path.clone()))
.answers(move |()| Ok(path.clone()))
.at_least_times(1)
}

pub fn data_dir_mock() -> impl Clause {
DataDirMock
.each_call(matching!())
.answers(|_| Ok(std::path::PathBuf::from("/data")))
.answers(|()| Ok(std::path::PathBuf::from("/data")))
.at_least_times(1)
}

Expand Down
4 changes: 2 additions & 2 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl Registry {
bail!("Project {project_name} does not exist");
}

for (name, project) in &mut self.projects.iter_mut() {
for (name, project) in &mut self.projects {
if project.port == linked_port {
// Take the port from the project so that it can be used by the linked port
project.port = self.allocator.allocate(deps, None)?;
Expand Down Expand Up @@ -598,7 +598,7 @@ linked_port = 3000",
assert!(registry
.create(
&mocked_deps,
&"app4",
"app4",
Some(PathBuf::from("/projects/app3")),
None,
)
Expand Down

0 comments on commit 6a2673e

Please sign in to comment.