|
@@ -46,28 +46,27 @@ func (sp *SyncProducer) SendMessage(msg *sarama.ProducerMessage) (partition int3
|
|
|
expectation := sp.expectations[0]
|
|
|
sp.expectations = sp.expectations[1:]
|
|
|
if expectation.CheckFunction != nil {
|
|
|
- if val, err := msg.Value.Encode(); err != nil {
|
|
|
+ val, err := msg.Value.Encode()
|
|
|
+ if err != nil {
|
|
|
sp.t.Errorf("Input message encoding failed: %s", err.Error())
|
|
|
return -1, -1, err
|
|
|
- } else {
|
|
|
- err := expectation.CheckFunction(val)
|
|
|
- if err != nil {
|
|
|
- sp.t.Errorf("Check function returned an error: %s", err.Error())
|
|
|
- return -1, -1, err
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ errCheck := expectation.CheckFunction(val)
|
|
|
+ if errCheck != nil {
|
|
|
+ sp.t.Errorf("Check function returned an error: %s", errCheck.Error())
|
|
|
+ return -1, -1, err
|
|
|
}
|
|
|
}
|
|
|
if expectation.Result == errProduceSuccess {
|
|
|
sp.lastOffset++
|
|
|
msg.Offset = sp.lastOffset
|
|
|
return 0, msg.Offset, nil
|
|
|
- } else {
|
|
|
- return -1, -1, expectation.Result
|
|
|
}
|
|
|
- } else {
|
|
|
- sp.t.Errorf("No more expectation set on this mock producer to handle the input message.")
|
|
|
- return -1, -1, errOutOfExpectations
|
|
|
+ return -1, -1, expectation.Result
|
|
|
}
|
|
|
+ sp.t.Errorf("No more expectation set on this mock producer to handle the input message.")
|
|
|
+ return -1, -1, errOutOfExpectations
|
|
|
}
|
|
|
|
|
|
|
|
@@ -89,10 +88,9 @@ func (sp *SyncProducer) SendMessages(msgs []*sarama.ProducerMessage) error {
|
|
|
|
|
|
}
|
|
|
return nil
|
|
|
- } else {
|
|
|
- sp.t.Errorf("Insufficient expectations set on this mock producer to handle the input messages.")
|
|
|
- return errOutOfExpectations
|
|
|
}
|
|
|
+ sp.t.Errorf("Insufficient expectations set on this mock producer to handle the input messages.")
|
|
|
+ return errOutOfExpectations
|
|
|
}
|
|
|
|
|
|
|