File tree Expand file tree Collapse file tree
elasticgraph-proto_ingestion/spec/unit/elastic_graph/proto_ingestion/schema_definition Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( /\A import / ) . 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 |
You can’t perform that action at this time.
0 commit comments