Skip to content

Commit

Permalink
Test that consumer can seek back to an already resolved offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevon committed Jan 29, 2021
1 parent 9514382 commit 18c78d1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/consumer/__tests__/seek.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Consumer', () => {
})
await consumer.subscribe({ topic: topicName, fromBeginning: true })

const messagesConsumed = []
let messagesConsumed = []
consumer.run({
autoCommit: false,
eachMessage: async event => messagesConsumed.push(event),
Expand All @@ -208,6 +208,22 @@ describe('Consumer', () => {
offset: '-1',
}),
])

messagesConsumed = []
consumer.seek({ topic: topicName, partition: 0, offset: 1 })

await expect(waitForMessages(messagesConsumed, { number: 2 })).resolves.toEqual([
{
topic: topicName,
partition: 0,
message: expect.objectContaining({ offset: '1' }),
},
{
topic: topicName,
partition: 0,
message: expect.objectContaining({ offset: '2' }),
},
])
})
})
})
Expand Down

0 comments on commit 18c78d1

Please sign in to comment.