Skip to content

Commit

Permalink
Add test for extensions in proto path
Browse files Browse the repository at this point in the history
  • Loading branch information
oldergod committed Aug 16, 2023
1 parent a551023 commit 123b26a
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,40 @@ class SchemaTest {
assertThat(schema.protoFile("squareup/domain/message.proto")).isNotNull()
}

@Test
fun extensionInProtoPathDontLoad() {
val schema = buildSchema {
add(
"a/original.proto".toPath(),
"""
|syntax = "proto2";
|package a;
|message A {
| optional string one = 1;
|}
""".trimMargin(),
)
addProtoPath(
"b/extension.proto".toPath(),
"""
|syntax = "proto2";
|package b;
|import "a/original.proto";
|extend a.A {
| optional string two = 2;
|}
""".trimMargin(),
)
}
val fields = (schema.getType("a.A") as MessageType).fields
assertThat(fields).hasSize(1)
with(fields[0]) {
assertThat(namespaces).isEqualTo(listOf("a", "A"))
assertThat(name).isEqualTo("one")
assertThat(isExtension).isEqualTo(false)
}
}

@Test
fun optionsWithRelativePathUsedInExtensions() {
val schema = buildSchema {
Expand Down

0 comments on commit 123b26a

Please sign in to comment.