offset_commit_response_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package sarama
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. var (
  7. emptyOffsetCommitResponse = []byte{
  8. 0x00, 0x00, 0x00, 0x00}
  9. )
  10. func TestEmptyOffsetCommitResponse(t *testing.T) {
  11. response := OffsetCommitResponse{}
  12. testResponse(t, "empty", &response, emptyOffsetCommitResponse)
  13. }
  14. func TestNormalOffsetCommitResponse(t *testing.T) {
  15. response := OffsetCommitResponse{}
  16. response.AddError("t", 0, ErrNotLeaderForPartition)
  17. response.Errors["m"] = make(map[int32]KError)
  18. // The response encoded form cannot be checked for it varies due to
  19. // unpredictable map traversal order.
  20. testResponse(t, "normal", &response, nil)
  21. }
  22. func TestOffsetCommitResponseWithThrottleTime(t *testing.T) {
  23. for version := 3; version <= 4; version++ {
  24. response := OffsetCommitResponse{
  25. Version: int16(version),
  26. ThrottleTimeMs: 123,
  27. }
  28. response.AddError("t", 0, ErrNotLeaderForPartition)
  29. response.Errors["m"] = make(map[int32]KError)
  30. // The response encoded form cannot be checked for it varies due to
  31. // unpredictable map traversal order.
  32. testResponse(t, fmt.Sprintf("v%d with throttle time", version), &response, nil)
  33. }
  34. }