Skip to content

Commit 5cd08a0

Browse files
authored
Fix flaky tests and resolve cargo clippy warnings (#31)
* Fix sorting issue in flaky specs * Resolve clippy warnings * Update pre-commit clippy config matches upcoming change to GH workflow
1 parent dabef4e commit 5cd08a0

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

.rusty-hook.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[hooks]
2-
pre-commit = "cargo clippy -- -Dwarnings && cargo test && cargo fmt -- --check"
2+
pre-commit = "cargo clippy --all-targets --all-features -- -D warnings && cargo test && cargo fmt -- --check"
33

44
[logging]
55
verbose = true

src/common_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ team_file_glob:
237237
.to_owned(),
238238
}],
239239
);
240-
Ok(build_ownership(test_config)?)
240+
build_ownership(test_config)
241241
}
242242
pub fn build_ownership_with_team_gem_codeowners() -> Result<Ownership, Box<dyn Error>> {
243243
ownership!(
@@ -264,7 +264,7 @@ team_file_glob:
264264
let temp_dir = tempdir()?;
265265

266266
let test_config = TestConfig::new(temp_dir.path().to_path_buf(), vec![]);
267-
Ok(build_ownership(test_config)?)
267+
build_ownership(test_config)
268268
}
269269
pub fn build_ownership_with_package_codeowners() -> Result<Ownership, Box<dyn Error>> {
270270
ownership!(

src/ownership/mapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mod tests {
6262
team_name: team_name.clone(),
6363
source: source.clone(),
6464
};
65-
let response = owner_matcher.owner_for(&Path::new(relative_path));
65+
let response = owner_matcher.owner_for(Path::new(relative_path));
6666
if expect_match {
6767
assert_eq!(response, (Some(&team_name), &source));
6868
} else {

src/ownership/mapper/team_file_mapper.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,19 @@ mod tests {
7676
fn test_entries() -> Result<(), Box<dyn Error>> {
7777
let ownership = build_ownership_with_all_mappers()?;
7878
let mapper = TeamFileMapper::build(ownership.project.clone());
79-
let entries = mapper.entries();
79+
let mut entries = mapper.entries();
80+
entries.sort_by_key(|e| e.path.clone());
8081
assert_eq!(
8182
entries,
8283
vec![
8384
Entry {
84-
path: "packs/zebra/app/services/team_file_owned.rb".to_owned(),
85+
path: "packs/jscomponents/comp.ts".to_owned(),
8586
github_team: "@Foo".to_owned(),
8687
team_name: "Foo".to_owned(),
8788
disabled: false
8889
},
8990
Entry {
90-
path: "packs/jscomponents/comp.ts".to_owned(),
91+
path: "packs/zebra/app/services/team_file_owned.rb".to_owned(),
9192
github_team: "@Foo".to_owned(),
9293
team_name: "Foo".to_owned(),
9394
disabled: false

src/ownership/mapper/team_yml_mapper.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ mod tests {
5858
fn test_entries() -> Result<(), Box<dyn Error>> {
5959
let ownership = build_ownership_with_all_mappers()?;
6060
let mapper = TeamYmlMapper::build(ownership.project.clone());
61-
let entries = mapper.entries();
61+
let mut entries = mapper.entries();
62+
entries.sort_by_key(|e| e.path.clone());
6263
assert_eq!(
6364
entries,
6465
vec![
6566
Entry {
66-
path: "config/teams/foo.yml".to_owned(),
67-
github_team: "@Foo".to_owned(),
68-
team_name: "Foo".to_owned(),
67+
path: "config/teams/bam.yml".to_owned(),
68+
github_team: "@Bam".to_owned(),
69+
team_name: "Bam".to_owned(),
6970
disabled: false
7071
},
7172
Entry {
@@ -74,17 +75,17 @@ mod tests {
7475
team_name: "Bar".to_owned(),
7576
disabled: false
7677
},
77-
Entry {
78-
path: "config/teams/bam.yml".to_owned(),
79-
github_team: "@Bam".to_owned(),
80-
team_name: "Bam".to_owned(),
81-
disabled: false
82-
},
8378
Entry {
8479
path: "config/teams/baz.yml".to_owned(),
8580
github_team: "@Baz".to_owned(),
8681
team_name: "Baz".to_owned(),
8782
disabled: false
83+
},
84+
Entry {
85+
path: "config/teams/foo.yml".to_owned(),
86+
github_team: "@Foo".to_owned(),
87+
team_name: "Foo".to_owned(),
88+
disabled: false
8889
}
8990
]
9091
);

0 commit comments

Comments
 (0)