alter_partition_reassignments_response_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package sarama
  2. import "testing"
  3. var (
  4. alterPartitionReassignmentsResponseNoError = []byte{
  5. 0, 0, 39, 16, // ThrottleTimeMs 10000
  6. 0, 0, // errorcode
  7. 0, // null string
  8. 1, // empty errors array
  9. 0, // empty tagged fields
  10. }
  11. alterPartitionReassignmentsResponseWithError = []byte{
  12. 0, 0, 39, 16, // ThrottleTimeMs 10000
  13. 0, 12, // errorcode
  14. 6, 101, 114, 114, 111, 114, // error string "error"
  15. 2, // errors array length 1
  16. 6, 116, 111, 112, 105, 99, // topic name "topic"
  17. 2, // partition array length 1
  18. 0, 0, 0, 1, // partitionId
  19. 0, 3, //kerror
  20. 7, 101, 114, 114, 111, 114, 50, // error string "error2"
  21. 0, 0, 0, // empty tagged fields
  22. }
  23. )
  24. func TestAlterPartitionReassignmentResponse(t *testing.T) {
  25. var response *AlterPartitionReassignmentsResponse
  26. response = &AlterPartitionReassignmentsResponse{
  27. ThrottleTimeMs: int32(10000),
  28. Version: int16(0),
  29. }
  30. testResponse(t, "no error", response, alterPartitionReassignmentsResponseNoError)
  31. errorMessage := "error"
  32. partitionError := "error2"
  33. response.ErrorCode = 12
  34. response.ErrorMessage = &errorMessage
  35. response.AddError("topic", 1, 3, &partitionError)
  36. testResponse(t, "with error", response, alterPartitionReassignmentsResponseWithError)
  37. }