(t *testing.T, partitioner Partitioner, numPartitions int32, testCase partitionerTestCase)
| 36 | } |
| 37 | |
| 38 | func 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 | |
| 55 | func TestRandomPartitioner(t *testing.T) { |
| 56 | partitioner := NewRandomPartitioner("mytopic") |
no test coverage detected