Skip to content

Commit

Permalink
Merge pull request #417 from Shopify/refactor_offset_commit_request_t…
Browse files Browse the repository at this point in the history
…ests

Refactor offset commit request tests so they don't cause warnings
  • Loading branch information
wvanbergen committed Apr 13, 2015
2 parents d779673 + e6dbbeb commit 0fc4105
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions offset_commit_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,37 @@ var (
0x00, 0x08, 'm', 'e', 't', 'a', 'd', 'a', 't', 'a'}
)

func TestOffsetCommitRequest(t *testing.T) {
func TestOffsetCommitRequestV0(t *testing.T) {
request := new(OffsetCommitRequest)

request.Version = 0
request.ConsumerGroup = "foobar"
testEncodable(t, "no blocks v0", request, offsetCommitRequestNoBlocksV0)

request.ConsumerGroupGeneration = 0x1122
request.AddBlock("topic", 0x5221, 0xDEADBEEF, 0, "metadata")
testEncodable(t, "one block v0", request, offsetCommitRequestOneBlockV0)
}

func TestOffsetCommitRequestV1(t *testing.T) {
request := new(OffsetCommitRequest)
request.ConsumerGroup = "foobar"
request.ConsumerID = "cons"
request.ConsumerGroupGeneration = 0x1122
request.Version = 1
testEncodable(t, "no blocks v1", request, offsetCommitRequestNoBlocksV1)

request.RetentionTime = 0x4433
request.Version = 2
testEncodable(t, "no blocks v2", request, offsetCommitRequestNoBlocksV2)

request.AddBlock("topic", 0x5221, 0xDEADBEEF, ReceiveTime, "metadata")
request.Version = 0
testEncodable(t, "one block v0", request, offsetCommitRequestOneBlockV0)

request.Version = 1
testEncodable(t, "one block v1", request, offsetCommitRequestOneBlockV1)
}

func TestOffsetCommitRequestV2(t *testing.T) {
request := new(OffsetCommitRequest)
request.ConsumerGroup = "foobar"
request.ConsumerID = "cons"
request.ConsumerGroupGeneration = 0x1122
request.RetentionTime = 0x4433
request.Version = 2
testEncodable(t, "no blocks v2", request, offsetCommitRequestNoBlocksV2)

request.AddBlock("topic", 0x5221, 0xDEADBEEF, 0, "metadata")
testEncodable(t, "one block v2", request, offsetCommitRequestOneBlockV2)
}

0 comments on commit 0fc4105

Please sign in to comment.