git-utils: fix selected filter edge cases

This commit is contained in:
Chris Bookholt
2026-07-01 15:17:42 -07:00
parent 0b84913ea8
commit 5b1fe8c0f2
5 changed files with 407 additions and 22 deletions
+14 -4
View File
@@ -57,6 +57,14 @@ fn selected_filter_policy_allows_effective_empty_value() {
);
}
#[test]
fn filter_driver_parser_accepts_empty_name() {
assert_eq!(
filter_driver_name("filter..clean").expect("empty filter name"),
""
);
}
#[test]
fn filter_attribute_parser_rejects_malformed_or_unexpected_records() {
let paths = vec![b"a.txt".to_vec(), b"b.txt".to_vec()];
@@ -64,12 +72,14 @@ fn filter_attribute_parser_rejects_malformed_or_unexpected_records() {
parse_filter_attributes(b"a.txt\0filter\0unspecified\0b.txt\0filter\0lfs\0", &paths)
.expect("parse attributes");
assert_eq!(
parsed.get(b"a.txt".as_slice()).map(String::as_str),
Some("unspecified")
parsed.get(b"a.txt".as_slice()),
Some(&FilterAttributeValue::AmbiguousSentinel(
"unspecified".to_string()
))
);
assert_eq!(
parsed.get(b"b.txt".as_slice()).map(String::as_str),
Some("lfs")
parsed.get(b"b.txt".as_slice()),
Some(&FilterAttributeValue::Driver("lfs".to_string()))
);
for output in [