offset_request_test.go 600 B

1234567891011121314151617181920212223242526
  1. package sarama
  2. import "testing"
  3. var (
  4. offsetRequestNoBlocks = []byte{
  5. 0xFF, 0xFF, 0xFF, 0xFF,
  6. 0x00, 0x00, 0x00, 0x00}
  7. offsetRequestOneBlock = []byte{
  8. 0xFF, 0xFF, 0xFF, 0xFF,
  9. 0x00, 0x00, 0x00, 0x01,
  10. 0x00, 0x03, 'f', 'o', 'o',
  11. 0x00, 0x00, 0x00, 0x01,
  12. 0x00, 0x00, 0x00, 0x04,
  13. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  14. 0x00, 0x00, 0x00, 0x02}
  15. )
  16. func TestOffsetRequest(t *testing.T) {
  17. request := new(OffsetRequest)
  18. testRequest(t, "no blocks", request, offsetRequestNoBlocks)
  19. request.AddBlock("foo", 4, 1, 2)
  20. testRequest(t, "one block", request, offsetRequestOneBlock)
  21. }