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

Function TestRandomPartitioner

partitioner_test.go:55–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestRandomPartitioner(t *testing.T) {
56 partitioner := NewRandomPartitioner("mytopic")
57
58 choice, err := partitioner.Partition(nil, 1)
59 if err != nil {
60 t.Error(partitioner, err)
61 }
62 if choice != 0 {
63 t.Error("Returned non-zero partition when only one available.")
64 }
65
66 for i := 1; i < 50; i++ {
67 choice, err := partitioner.Partition(nil, 50)
68 if err != nil {
69 t.Error(partitioner, err)
70 }
71 if choice < 0 || choice >= 50 {
72 t.Error("Returned partition", choice, "outside of range.")
73 }
74 }
75}
76
77func TestRoundRobinPartitioner(t *testing.T) {
78 partitioner := NewRoundRobinPartitioner("mytopic")

Callers

nothing calls this directly

Calls 3

NewRandomPartitionerFunction · 0.85
PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected