fetch_request_test.go 1019 B

12345678910111213141516171819202122232425262728293031323334
  1. package sarama
  2. import "testing"
  3. var (
  4. fetchRequestNoBlocks = []byte{
  5. 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6. 0x00, 0x00, 0x00, 0x00}
  7. fetchRequestWithProperties = []byte{
  8. 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xEF,
  9. 0x00, 0x00, 0x00, 0x00}
  10. fetchRequestOneBlock = []byte{
  11. 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  12. 0x00, 0x00, 0x00, 0x01,
  13. 0x00, 0x05, 't', 'o', 'p', 'i', 'c',
  14. 0x00, 0x00, 0x00, 0x01,
  15. 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x56}
  16. )
  17. func TestFetchRequest(t *testing.T) {
  18. request := new(FetchRequest)
  19. testRequest(t, "no blocks", request, fetchRequestNoBlocks)
  20. request.MaxWaitTime = 0x20
  21. request.MinBytes = 0xEF
  22. testRequest(t, "with properties", request, fetchRequestWithProperties)
  23. request.MaxWaitTime = 0
  24. request.MinBytes = 0
  25. request.AddBlock("topic", 0x12, 0x34, 0x56)
  26. testRequest(t, "one block", request, fetchRequestOneBlock)
  27. }