Skip to content

Commit

Permalink
fix: shared prefix false match
Browse files Browse the repository at this point in the history
  • Loading branch information
cobbinma committed May 31, 2022
1 parent 6817ed9 commit 59fd6da
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pbjson-build/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> Resolver<'a> {
.path()
.iter()
.zip(path.path())
.filter(|(a, b)| a == b)
.take_while(|(a, b)| a == b)
.count();

let super_count = self.package.path().len() - shared_prefix;
Expand Down Expand Up @@ -176,6 +176,19 @@ mod tests {
);
}

#[test]
// https://github.com/influxdata/pbjson/issues/48
fn test_resolver_shared_prefix_false_match() {
assert_eq!(
Resolver::new(&[], &Package::new("test.api.v1"), false).rust_type(
&TypePath::new(Package::new("test.domain.v1"))
.child(TypeName::new("Foo"))
.child(TypeName::new("Bar"))
),
"super::super::domain::v1::foo::Bar"
);
}

#[test]
fn test_variant() {
let package = Package::new("test.syntax3");
Expand Down

0 comments on commit 59fd6da

Please sign in to comment.