-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathfetched_batch_spec.rb
45 lines (42 loc) · 1.25 KB
/
fetched_batch_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
describe Kafka::FetchedBatch do
describe "#offset_lag" do
context "empty batch" do
it "is 0" do
fetched_batch = described_class.new(
topic: 'foo',
partition: 0,
highwater_mark_offset: 10,
messages: []
)
expect(fetched_batch.offset_lag).to eq 0
end
end
context "batch contains last message in partition" do
let(:message) { double(:message, offset: 9) }
it "is 0" do
fetched_batch = described_class.new(
topic: 'foo',
partition: 0,
last_offset: 9,
highwater_mark_offset: 10, # offset of *next* message
messages: [message]
)
expect(fetched_batch.offset_lag).to eq 0
end
end
context "batch does not contain last message in partition" do
let(:message) { double(:message, offset: 9) }
it "is the difference between last offset in batch and partition" do
fetched_batch = described_class.new(
topic: 'foo',
partition: 0,
last_offset: 9,
highwater_mark_offset: 12, # offset of *next* message
messages: [message]
)
expect(fetched_batch.offset_lag).to eq 2
end
end
end
end