Skip to content

Commit 1517403

Browse files
authored
Merge pull request #939 from Shopify/versionable-mock-fetch-response
Permit setting version on mock fetch response
2 parents 2fcb056 + 6eaa181 commit 1517403

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mockresponses.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ type MockFetchResponse struct {
180180
highWaterMarks map[string]map[int32]int64
181181
t TestReporter
182182
batchSize int
183+
version int16
183184
}
184185

185186
func NewMockFetchResponse(t TestReporter, batchSize int) *MockFetchResponse {
@@ -191,6 +192,11 @@ func NewMockFetchResponse(t TestReporter, batchSize int) *MockFetchResponse {
191192
}
192193
}
193194

195+
func (mfr *MockFetchResponse) SetVersion(version int16) *MockFetchResponse {
196+
mfr.version = version
197+
return mfr
198+
}
199+
194200
func (mfr *MockFetchResponse) SetMessage(topic string, partition int32, offset int64, msg Encoder) *MockFetchResponse {
195201
partitions := mfr.messages[topic]
196202
if partitions == nil {
@@ -218,7 +224,9 @@ func (mfr *MockFetchResponse) SetHighWaterMark(topic string, partition int32, of
218224

219225
func (mfr *MockFetchResponse) For(reqBody versionedDecoder) encoder {
220226
fetchRequest := reqBody.(*FetchRequest)
221-
res := &FetchResponse{}
227+
res := &FetchResponse{
228+
Version: mfr.version,
229+
}
222230
for topic, partitions := range fetchRequest.blocks {
223231
for partition, block := range partitions {
224232
initialOffset := block.fetchOffset

0 commit comments

Comments
 (0)