(t *testing.T, partitioner Partitioner, message *ProducerMessage, numPartitions int32)
| 12 | ) |
| 13 | |
| 14 | func assertPartitioningConsistent(t *testing.T, partitioner Partitioner, message *ProducerMessage, numPartitions int32) { |
| 15 | choice, err := partitioner.Partition(message, numPartitions) |
| 16 | if err != nil { |
| 17 | t.Error(partitioner, err) |
| 18 | } |
| 19 | if choice < 0 || choice >= numPartitions { |
| 20 | t.Error(partitioner, "returned partition", choice, "outside of range for", message) |
| 21 | } |
| 22 | for i := 1; i < 50; i++ { |
| 23 | newChoice, err := partitioner.Partition(message, numPartitions) |
| 24 | if err != nil { |
| 25 | t.Error(partitioner, err) |
| 26 | } |
| 27 | if newChoice != choice { |
| 28 | t.Error(partitioner, "returned partition", newChoice, "inconsistent with", choice, ".") |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | type partitionerTestCase struct { |
| 34 | key string |
no test coverage detected