MCPcopy
hub / github.com/IBM/sarama / TestRoundRobinPartitioner

Function TestRoundRobinPartitioner

partitioner_test.go:77–98  ·  partitioner_test.go::TestRoundRobinPartitioner
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestRoundRobinPartitioner(t *testing.T) {
78 partitioner := NewRoundRobinPartitioner("mytopic")
79
80 choice, err := partitioner.Partition(nil, 1)
81 if err != nil {
82 t.Error(partitioner, err)
83 }
84 if choice != 0 {
85 t.Error("Returned non-zero partition when only one available.")
86 }
87
88 var i int32
89 for i = 1; i < 50; i++ {
90 choice, err := partitioner.Partition(nil, 7)
91 if err != nil {
92 t.Error(partitioner, err)
93 }
94 if choice != i%7 {
95 t.Error("Returned partition", choice, "expecting", i%7)
96 }
97 }
98}
99
100func TestNewHashPartitionerWithHasher(t *testing.T) {
101 // use the current default hasher fnv.New32a()

Callers

nothing calls this directly

Calls 3

NewRoundRobinPartitionerFunction · 0.85
PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected