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

Function partitionAndAssert

partitioner_test.go:38–53  ·  view source on GitHub ↗
(t *testing.T, partitioner Partitioner, numPartitions int32, testCase partitionerTestCase)

Source from the content-addressed store, hash-verified

36}
37
38func partitionAndAssert(t *testing.T, partitioner Partitioner, numPartitions int32, testCase partitionerTestCase) {
39 t.Run("partitionAndAssert "+testCase.key, func(t *testing.T) {
40 msg := &ProducerMessage{
41 Key: StringEncoder(testCase.key),
42 }
43
44 partition, err := partitioner.Partition(msg, numPartitions)
45
46 if err != nil {
47 t.Error(partitioner, err)
48 }
49 if partition != testCase.expectedPartition {
50 t.Error(partitioner, "partitioning", testCase.key, "returned partition", partition, "but expected", testCase.expectedPartition, ".")
51 }
52 })
53}
54
55func TestRandomPartitioner(t *testing.T) {
56 partitioner := NewRandomPartitioner("mytopic")

Callers 1

Calls 4

StringEncoderTypeAlias · 0.85
RunMethod · 0.80
PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected