Skip to content

Commit 1aa384b

Browse files
committed
Test protobuf import stability
1 parent 37c1f3c commit 1aa384b

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • elasticgraph-proto_ingestion/spec/unit/elastic_graph/proto_ingestion/schema_definition

elasticgraph-proto_ingestion/spec/unit/elastic_graph/proto_ingestion/schema_definition/schema_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,38 @@ module SchemaDefinition
238238
PROTO
239239
end
240240

241+
it "sorts and de-duplicates imports shared by distinct protobuf types" do
242+
proto = define_proto_schema do |s|
243+
s.scalar_type "FirstZType" do |t|
244+
t.mapping type: "keyword"
245+
t.protobuf type: "example.FirstZType", import: "z/types.proto"
246+
end
247+
248+
s.scalar_type "SecondZType" do |t|
249+
t.mapping type: "keyword"
250+
t.protobuf type: "example.SecondZType", import: "z/types.proto"
251+
end
252+
253+
s.scalar_type "AType" do |t|
254+
t.mapping type: "keyword"
255+
t.protobuf type: "example.AType", import: "a/types.proto"
256+
end
257+
258+
s.object_type "Event" do |t|
259+
t.field "id", "ID"
260+
t.field "first_z", "FirstZType"
261+
t.field "second_z", "SecondZType"
262+
t.field "a", "AType"
263+
t.index "events"
264+
end
265+
end
266+
267+
expect(proto.lines.grep(/\Aimport /).map(&:chomp)).to eq([
268+
%(import "a/types.proto";),
269+
%(import "z/types.proto";)
270+
])
271+
end
272+
241273
it "renders format comments on fields whose scalar type documents one" do
242274
proto = define_proto_schema do |s|
243275
s.object_type "Person" do |t|

0 commit comments

Comments
 (0)