Skip to content

Commit

Permalink
Don't have a codepath we don't test for in the project middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot committed Jul 10, 2024
1 parent b88c80a commit c68d29a
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,15 @@ impl Project {
} else if let Some(fallback) = fallback {
self.name = Some(fallback.to_string());
} else {
for rule in self.sync_rules.iter().chain(default_sync_rules()) {
// I don't believe there's any way to get here without the
// matching middleware being a Project middleware.
if rule.matches(&self.file_location) {
self.name = Some(
rule.file_name_for_path(&self.file_location)
.map_err(|_| Error::ProjectNameInvalid {
path: self.file_location.clone(),
})?
.to_string(),
)
}
}
return Err(Error::ProjectNameInvalid {
path: std::mem::take(&mut self.file_location),
});
// As of the time of writing (July 10, 2024) there is no way for
// this code path to be reachable. It can in theory be reached from
// both `load_fuzzy` and `load_exact` but in practice it's never
// invoked.
// If you're adding this codepath, make sure a test for it exists
// and that it handles sync rules appropriately.
todo!(
"set_file_name doesn't support loading project files that aren't default.project.json without a fallback provided"
);
}

Ok(())
Expand Down

0 comments on commit c68d29a

Please sign in to comment.