sarama icon indicating copy to clipboard operation
sarama copied to clipboard

Mock broker set message header

Open XSAM opened this issue 4 years ago • 3 comments

Versions
Sarama Kafka Go
v1.26.4 N/A 1.14.2
Problem Description

I want to write some tests about the message header. Is there a way to set header to message?

broker := sarama.NewMockBroker(t, 0)
defer broker.Close()

broker.SetHandlerByMap(map[string]sarama.MockResponse{
	"MetadataRequest": sarama.NewMockMetadataResponse(t).
		SetBroker(broker.Addr(), broker.BrokerID()).
		SetLeader("test-topic", 0, broker.BrokerID()),
	"OffsetRequest": sarama.NewMockOffsetResponse(t).
		SetOffset("test-topic", 0, sarama.OffsetOldest, 0).
		SetOffset("test-topic", 0, sarama.OffsetNewest, 1),
	"FetchRequest": sarama.NewMockFetchResponse(t, 1).
		SetMessage("test-topic", 0, 0, sarama.StringEncoder("hello")).
})

Currently, I can only set the message.

SetMessage("test-topic", 0, 0, sarama.StringEncoder("hello"))

XSAM avatar Jul 09 '20 09:07 XSAM

Relates to https://github.com/Shopify/sarama/issues/1665

First version that supports headers is sarama.V0_11_0_0 and MockBroker doesn't work with it.

adw1n avatar Sep 21 '20 15:09 adw1n

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

ghost avatar Mar 16 '21 22:03 ghost

Are there any plans to support the sarama.V0_11_0_0 version by the MockBroker in order to test messages with headers?

Henrike42 avatar Mar 31 '22 07:03 Henrike42

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

github-actions[bot] avatar Nov 22 '23 22:11 github-actions[bot]

Any updates on MockBroker test messages with headers?

ehsaniara avatar Dec 31 '23 17:12 ehsaniara