offset_commit_request_test.go 1010 B

12345678910111213141516171819202122232425262728293031323334
  1. package sarama
  2. import "testing"
  3. var (
  4. offsetCommitRequestNoGroupNoBlocks = []byte{
  5. 0x00, 0x00,
  6. 0x00, 0x00, 0x00, 0x00}
  7. offsetCommitRequestNoBlocks = []byte{
  8. 0x00, 0x06, 'f', 'o', 'o', 'b', 'a', 'r',
  9. 0x00, 0x00, 0x00, 0x00}
  10. offsetCommitRequestOneBlock = []byte{
  11. 0x00, 0x06, 'f', 'o', 'o', 'b', 'a', 'r',
  12. 0x00, 0x00, 0x00, 0x01,
  13. 0x00, 0x05, 't', 'o', 'p', 'i', 'c',
  14. 0x00, 0x00, 0x00, 0x01,
  15. 0x00, 0x00, 0x52, 0x21,
  16. 0x00, 0x00, 0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF,
  17. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  18. 0x00, 0x08, 'm', 'e', 't', 'a', 'd', 'a', 't', 'a'}
  19. )
  20. func TestOffsetCommitRequest(t *testing.T) {
  21. request := new(OffsetCommitRequest)
  22. testEncodable(t, "no group, no blocks", request, offsetCommitRequestNoGroupNoBlocks)
  23. request.ConsumerGroup = "foobar"
  24. testEncodable(t, "no blocks", request, offsetCommitRequestNoBlocks)
  25. request.AddBlock("topic", 0x5221, 0xDEADBEEF, ReceiveTime, "metadata")
  26. testEncodable(t, "one block", request, offsetCommitRequestOneBlock)
  27. }