ignore/types: add automated test for sortedness

People occasionally get this wrong and I've been manually
checking it. Instead, let's have CI do it automatically.

PR #2351
This commit is contained in:
Armin Brauns 2022-11-14 14:31:07 +01:00 committed by GitHub
parent 8905d54a9f
commit 7f23cd63a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}
}