Skip to content

Commit a02d6c3

Browse files
jwilsmyronmarston
andcommitted
Update elasticgraph-indexer/spec/unit/elastic_graph/indexer/processor_spec.rb
Co-authored-by: Myron Marston <myron.marston@toasttab.com>
1 parent af7962e commit a02d6c3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎elasticgraph-indexer/spec/unit/elastic_graph/indexer/processor_spec.rb‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,19 @@ class Indexer
100100
original = build_upsert_event(:widget, id: "same-id", __version: 1)
101101
newer = original.with(version: 2)
102102
adapter = indexer.ingestion_adapters_by_format.fetch("json")
103+
operation_groups = nil
104+
103105
allow(adapter).to receive(:validate_event).and_wrap_original do |method, event, **options|
104106
result = method.call(event, **options)
105-
IngestionAdapter::ValidationResult.valid(
106-
result.event.with(record: result.event.record.merge("normalized" => true)), result.record_preparer
107-
)
107+
# Merge in an update to `event` to represent the adapter normalizing the event in some fashion.
108+
109+
event = result.event.with(record: result.event.record.merge("normalized" => true))
110+
IngestionAdapter::ValidationResult.valid(event, result.record_preparer)
108111
end
109-
operation_groups = nil
112+
110113
allow(datastore_router).to receive(:bulk) do |operations, **|
111114
operation_groups = operations.group_by(&:event)
115+
112116
DatastoreIndexingRouter::BulkResult.new({"main" => operations.map do |operation|
113117
result = if operation.event.version == 1
114118
Operation::Result.failure_of(operation, "failed normalized event")
@@ -120,6 +124,7 @@ class Indexer
120124
end
121125

122126
failures = process_returning_failures([original, newer])
127+
123128
expect(failures).not_to be_empty
124129
expect(failures.map(&:version).uniq).to eq([1])
125130
expect(failures.map(&:event)).to all have_attributes(record: a_hash_including("normalized" => true))

0 commit comments

Comments
 (0)