Skip to content

Commit

Permalink
ignore/types: add automated test for sortedness
Browse files Browse the repository at this point in the history
People occasionally get this wrong and I've been manually
checking it. Instead, let's have CI do it automatically.

PR #2351
  • Loading branch information
arbrauns authored Nov 14, 2022
1 parent 8905d54 commit 7f23cd6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/ignore/src/default_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,26 @@ pub const DEFAULT_TYPES: &[(&str, &[&str])] = &[
]),
("zstd", &["*.zst", "*.zstd"]),
];

#[cfg(test)]
mod tests {
use super::DEFAULT_TYPES;

#[test]
fn default_types_are_sorted() {
let mut names = DEFAULT_TYPES.iter().map(|(name, _exts)| name);

let Some(mut previous_name) = names.next() else { return; };

for name in names {
assert!(
name > previous_name,
r#""{}" should be sorted before "{}" in `DEFAULT_TYPES`"#,
name,
previous_name
);

previous_name = name;
}
}
}

0 comments on commit 7f23cd6

Please sign in to comment.