Skip to content

Commit

Permalink
Merge pull request IBM#2117 from wuhuizuo/feat/mock_api_version_respo…
Browse files Browse the repository at this point in the history
…nse_enhance

feat: add method MockApiVersionsResponse.SetApiKeys
  • Loading branch information
dnwe authored Jan 21, 2022
2 parents 26b2d15 + fd869bd commit 4ee6656
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions mockresponses.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,31 +1347,38 @@ func (m *MockDescribeLogDirsResponse) For(reqBody versionedDecoder) encoderWithH
}

type MockApiVersionsResponse struct {
t TestReporter
t TestReporter
apiKeys []ApiVersionsResponseKey
}

func NewMockApiVersionsResponse(t TestReporter) *MockApiVersionsResponse {
return &MockApiVersionsResponse{t: t}
}

func (mr *MockApiVersionsResponse) For(reqBody versionedDecoder) encoderWithHeader {
req := reqBody.(*ApiVersionsRequest)
res := &ApiVersionsResponse{
Version: req.Version,
ApiKeys: []ApiVersionsResponseKey{
return &MockApiVersionsResponse{
t: t,
apiKeys: []ApiVersionsResponseKey{
{
Version: req.Version,
ApiKey: 0,
MinVersion: 5,
MaxVersion: 8,
},
{
Version: req.Version,
ApiKey: 1,
MinVersion: 7,
MaxVersion: 11,
},
},
}
}

func (m *MockApiVersionsResponse) SetApiKeys(apiKeys []ApiVersionsResponseKey) *MockApiVersionsResponse {
m.apiKeys = apiKeys
return m
}

func (m *MockApiVersionsResponse) For(reqBody versionedDecoder) encoderWithHeader {
req := reqBody.(*ApiVersionsRequest)
res := &ApiVersionsResponse{
Version: req.Version,
ApiKeys: m.apiKeys,
}
return res
}

0 comments on commit 4ee6656

Please sign in to comment.