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

Function TestManualPartitioner

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

Source from the content-addressed store, hash-verified

268}
269
270func TestManualPartitioner(t *testing.T) {
271 partitioner := NewManualPartitioner("mytopic")
272
273 choice, err := partitioner.Partition(&ProducerMessage{}, 1)
274 if err != nil {
275 t.Error(partitioner, err)
276 }
277 if choice != 0 {
278 t.Error("Returned non-zero partition when only one available.")
279 }
280
281 for i := int32(1); i < 50; i++ {
282 choice, err := partitioner.Partition(&ProducerMessage{Partition: i}, 50)
283 if err != nil {
284 t.Error(partitioner, err)
285 }
286 if choice != i {
287 t.Error("Returned partition not the same as the input partition")
288 }
289 }
290}
291
292func TestWithCustomFallbackPartitioner(t *testing.T) {
293 topic := "mytopic"

Callers

nothing calls this directly

Calls 3

NewManualPartitionerFunction · 0.85
PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected