(t *testing.T)
| 246 | } |
| 247 | |
| 248 | func TestCustomPartitionerWithConsistentHashing(t *testing.T) { |
| 249 | // Setting both `hashUnsigned` and the hash function to `crc32.NewIEEE` is equivalent to using `NewConsistentCRCHashPartitioner` |
| 250 | partitioner := NewCustomPartitioner( |
| 251 | WithHashUnsigned(), |
| 252 | WithCustomHashFunction(crc32.NewIEEE), |
| 253 | )("mytopic") |
| 254 | |
| 255 | // See above re: why `SheetJS` |
| 256 | msg := ProducerMessage{ |
| 257 | Key: StringEncoder("SheetJS"), |
| 258 | } |
| 259 | |
| 260 | choice, err := partitioner.Partition(&msg, 100) |
| 261 | if err != nil { |
| 262 | t.Error(partitioner, err) |
| 263 | } |
| 264 | expectedPartition := int32(26) |
| 265 | if choice != expectedPartition { |
| 266 | t.Error(partitioner, "returned partition", choice, "but expected", expectedPartition, ".") |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | func TestManualPartitioner(t *testing.T) { |
| 271 | partitioner := NewManualPartitioner("mytopic") |
nothing calls this directly
no test coverage detected