12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package sarama
- import (
- "testing"
- )
- var (
- describeLogDirsResponseEmpty = []byte{
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- }
- describeLogDirsResponseTwoPartitions = []byte{
- 0, 0, 0, 0,
- 0, 0, 0, 1,
- 0, 0,
- 0, 6,
- '/', 'k', 'a', 'f', 'k', 'a',
- 0, 0, 0, 1,
- 0, 6,
- 'r', 'a', 'n', 'd', 'o', 'm',
- 0, 0, 0, 2,
- 0, 0, 0, 25,
- 0, 0, 0, 0, 0, 0, 0, 125,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0,
- 0, 0, 0, 26,
- 0, 0, 0, 0, 0, 0, 0, 100,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0,
- }
- )
- func TestDescribeLogDirsResponse(t *testing.T) {
-
- response := &DescribeLogDirsResponse{
- LogDirs: []DescribeLogDirsResponseDirMetadata{},
- }
- testVersionDecodable(t, "empty", response, describeLogDirsResponseEmpty, 0)
- if len(response.LogDirs) != 0 {
- t.Error("Expected no log dirs")
- }
- response.LogDirs = []DescribeLogDirsResponseDirMetadata{
- {
- ErrorCode: 0,
- Path: "/kafka",
- Topics: []DescribeLogDirsResponseTopic{
- {
- Topic: "random",
- Partitions: []DescribeLogDirsResponsePartition{
- {
- PartitionID: 25,
- Size: 125,
- OffsetLag: 0,
- IsTemporary: false,
- },
- {
- PartitionID: 26,
- Size: 100,
- OffsetLag: 0,
- IsTemporary: false,
- },
- },
- },
- },
- },
- }
- testVersionDecodable(t, "two partitions", response, describeLogDirsResponseTwoPartitions, 0)
- if len(response.LogDirs) != 1 {
- t.Error("Expected one log dirs")
- }
- if len(response.LogDirs[0].Topics) != 1 {
- t.Error("Expected one topic in log dirs")
- }
- if len(response.LogDirs[0].Topics[0].Partitions) != 2 {
- t.Error("Expected two partitions")
- }
- }
|