Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Oct 9, 2023
1 parent 126c5f4 commit ecf933d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ internal fun Schema.partition(modules: Map<String, Module>): PartitionedSchema {
}
}

return PartitionedSchema(partitions, warnings, errors)
return PartitionedSchema(partitions, warnings, errors)
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,62 @@ class ManifestPartitionTest {
""".trimMargin(),
)
}

@Test fun something() {
val schema = buildSchema {
add(
"first.proto".toPath(),
"""
|syntax = "proto2";
|package com.squareup.wire.first;
|
|message Card {
| enum Brand {
| DO_NOT_USE = 1;
| }
| optional string name = 1;
|}
|
""".trimMargin(),
)

add(
"second.proto".toPath(),
"""
|syntax = "proto2";
|package com.squareup.wire.second;
|
|import "first.proto";
|
|message Details {
| optional com.squareup.wire.first.Card.Brand brand = 1;
|}
|
""".trimMargin(),
)
}

val modules = mapOf(
"first" to WireRun.Module(
pruningRules = PruningRules.Builder()
.addRoot("com.squareup.wire.first.Card")
.build(),
),
"second" to WireRun.Module(
dependencies = setOf("first"),
pruningRules = PruningRules.Builder()
.addRoot("com.squareup.wire.second.Details")
.build(),
),
)

val partitionedSchema = schema.partition(modules)

val firstPartition = partitionedSchema.partitions.getValue("first")

assertThat(firstPartition.types).contains(ProtoType.get("com.squareup.wire.first.Card"))
assertThat(firstPartition.types).contains(ProtoType.get("com.squareup.wire.first.Card.Brand"))
}
}

private fun Schema.getMessage(name: String): MessageType {
Expand Down

0 comments on commit ecf933d

Please sign in to comment.