Skip to content

Commit b145edc

Browse files
committed
Cover finding protobuf metadata among other indexer extensions
Protobuf metadata is appended after any user-registered indexer extension, so a lookup that picked the first extension would pass every other spec. Co-authored-by: Josh Wilson <joshuaw@squareup.com> Signed-off-by: Josh Wilson <joshuaw@squareup.com>
1 parent d613202 commit b145edc

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎elasticgraph-proto_ingestion/spec/integration/elastic_graph/proto_ingestion/record_preparer_spec.rb‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ module ProtoIngestion
174174
end
175175
end
176176

177+
it "finds the protobuf runtime metadata among other registered indexer extensions" do
178+
stub_const("OtherIndexerExtension", ::Module.new)
179+
artifacts = define_proto_schema_results do |schema|
180+
schema.proto_schema_artifacts package_name: "preparation"
181+
# `defined_at` just needs a valid require path, but needs to be outside ElasticGraph
182+
# to not mess with our code coverage measurement.
183+
schema.register_indexer_extension OtherIndexerExtension, defined_at: "time"
184+
185+
schema.object_type("Item") do |type|
186+
type.field "id", "ID!"
187+
type.field "label", "String", name_in_index: "private_label"
188+
type.index "items"
189+
end
190+
end
191+
native = native_record({"label" => "sample"}, type: "Item", via: SpecSupport::ProtoPublisher.new(artifacts))
192+
193+
expect(prepare(native, type: "Item", via: described_class.new(artifacts))).to eq("private_label" => "sample")
194+
end
195+
177196
it "raises a clear error when the schema artifacts lack protobuf runtime metadata" do
178197
artifacts = define_schema(schema_element_name_form: :snake_case) do |schema|
179198
schema.object_type("Item") do |type|

0 commit comments

Comments
 (0)