Batch disposition calls return nil rather than 0 value
This commit is contained in:
Родитель
472f292a6c
Коммит
f5d2fee376
|
@ -65,8 +65,8 @@ func (bdi *BatchDispositionIterator) Next() (uuid *uuid.UUID) {
|
|||
return uuid
|
||||
}
|
||||
|
||||
func (bdi *BatchDispositionIterator) doUpdate(ctx context.Context, ec entityConnector) BatchDispositionError {
|
||||
batchError := BatchDispositionError{}
|
||||
func (bdi *BatchDispositionIterator) doUpdate(ctx context.Context, ec entityConnector) *BatchDispositionError {
|
||||
var batchError *BatchDispositionError
|
||||
for !bdi.Done() {
|
||||
if id := bdi.Next(); id != nil {
|
||||
m := &Message{
|
||||
|
@ -75,6 +75,9 @@ func (bdi *BatchDispositionIterator) doUpdate(ctx context.Context, ec entityConn
|
|||
m.ec = ec
|
||||
err := m.sendDisposition(ctx, bdi.Status)
|
||||
if err != nil {
|
||||
if batchError == nil {
|
||||
batchError = new(BatchDispositionError)
|
||||
}
|
||||
batchError.Errors = append(batchError.Errors, DispositionError{
|
||||
LockTokenID: id,
|
||||
err: err,
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestBatchDispositionUnsupportedStatus(t *testing.T) {
|
|||
receivingEntity: newReceivingEntity(newEntity("foo", "bar", nil)),
|
||||
}
|
||||
err := subscription.SendBatchDisposition(context.Background(), bdi)
|
||||
be := err.(BatchDispositionError)
|
||||
be := err.(*BatchDispositionError)
|
||||
assert.NotNil(t, be, fmt.Sprintf("Wrong error type %T", err))
|
||||
assert.EqualErrorf(t, err, fmt.Sprintf("Operation failed, %d error(s) reported.", len(be.Errors)), err.Error())
|
||||
|
||||
|
@ -55,3 +55,17 @@ func TestBatchDispositionUnsupportedStatus(t *testing.T) {
|
|||
assert.EqualErrorf(t, innerErr, "unsupported bulk disposition status \"suspended\"", innerErr.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchDispositiondoUpdateNoError(t *testing.T) {
|
||||
//want done to return immediately on a call to Done
|
||||
//so no error can be generated, we can do that by
|
||||
//placing an empty slice for the lock tokens
|
||||
bdi := BatchDispositionIterator{
|
||||
LockTokenIDs: []*uuid.UUID{},
|
||||
}
|
||||
|
||||
//using nil for the entity connector as it will never be called
|
||||
result := bdi.doUpdate(context.Background(), nil)
|
||||
|
||||
assert.Nil(t, result, fmt.Sprintf("Expected a nil error to be returned got %v", result))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче