offset_fetch_request_test.go 875 B

12345678910111213141516171819202122232425262728293031
  1. package sarama
  2. import "testing"
  3. var (
  4. offsetFetchRequestNoGroupNoPartitions = []byte{
  5. 0x00, 0x00,
  6. 0x00, 0x00, 0x00, 0x00}
  7. offsetFetchRequestNoPartitions = []byte{
  8. 0x00, 0x04, 'b', 'l', 'a', 'h',
  9. 0x00, 0x00, 0x00, 0x00}
  10. offsetFetchRequestOnePartition = []byte{
  11. 0x00, 0x04, 'b', 'l', 'a', 'h',
  12. 0x00, 0x00, 0x00, 0x01,
  13. 0x00, 0x0D, 't', 'o', 'p', 'i', 'c', 'T', 'h', 'e', 'F', 'i', 'r', 's', 't',
  14. 0x00, 0x00, 0x00, 0x01,
  15. 0x4F, 0x4F, 0x4F, 0x4F}
  16. )
  17. func TestOffsetFetchRequest(t *testing.T) {
  18. request := new(OffsetFetchRequest)
  19. testRequest(t, "no group, no partitions", request, offsetFetchRequestNoGroupNoPartitions)
  20. request.ConsumerGroup = "blah"
  21. testRequest(t, "no partitions", request, offsetFetchRequestNoPartitions)
  22. request.AddPartition("topicTheFirst", 0x4F4F4F4F)
  23. testRequest(t, "one partition", request, offsetFetchRequestOnePartition)
  24. }