Skip to content

Commit

Permalink
validator: flag osm=ref in refstreets
Browse files Browse the repository at this point in the history
The whole point of refstreets is to map between ref and osm, so if it's
the same, then the entry should be just removed.

Addresses <#3850>.

Change-Id: Ie69dbcd024bfd159a5835b3890efe4c17ecebcf0
  • Loading branch information
vmiklos committed Apr 26, 2024
1 parent 6a043ba commit 1af8119
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ fn validate_refstreets(
if value.contains('\'') || value.contains('"') {
errors.push(format!("expected no quotes in value of '{context}{key}'"));
}
if key == value {
errors.push(format!("expected value != key for '{context}{key}'"));
}
}
let mut reverse: Vec<_> = refstreets
.iter()
Expand Down
12 changes: 12 additions & 0 deletions src/validator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ failed to validate {0}
assert_failure_msg(content, expected);
}

/// Tests the relation path: bad refstreets value, osm=ref.
#[test]
fn test_relation_refstreets_bad_value() {
let content = r#"refstreets:
'OSM Name 1': 'OSM Name 1'
"#;
let expected = r#"expected value != key for 'refstreets.OSM Name 1'
failed to validate {0}
"#;
assert_failure_msg(content, expected);
}

/// Tests the relation path: bad filters -> ... -> invalid subkey.
#[test]
fn test_relation_filters_invalid_bad2() {
Expand Down

0 comments on commit 1af8119

Please sign in to comment.