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

Function TestHashPartitionerWithHasherMinInt32

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

Source from the content-addressed store, hash-verified

129}
130
131func TestHashPartitionerWithHasherMinInt32(t *testing.T) {
132 // use the current default hasher fnv.New32a()
133 partitioner := NewCustomHashPartitioner(fnv.New32a)("mytopic")
134
135 msg := ProducerMessage{}
136 // "1468509572224" generates 2147483648 (uint32) result from Sum32 function
137 // which is -2147483648 or int32's min value
138 msg.Key = StringEncoder("1468509572224")
139
140 choice, err := partitioner.Partition(&msg, 50)
141 if err != nil {
142 t.Error(partitioner, err)
143 }
144 if choice < 0 || choice >= 50 {
145 t.Error("Returned partition", choice, "outside of range for nil key.")
146 }
147}
148
149func TestHashPartitioner(t *testing.T) {
150 partitioner := NewHashPartitioner("mytopic")

Callers

nothing calls this directly

Calls 4

NewCustomHashPartitionerFunction · 0.85
StringEncoderTypeAlias · 0.85
PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected