Skip to content

Commit

Permalink
Adding BatchWriteItemWithContext
Browse files Browse the repository at this point in the history
This patch introduces BatchWriteItemWithContext API which
has same body of BatchWriteItem.
  • Loading branch information
sangdeug.kim committed Oct 8, 2019
1 parent b1eca1f commit 261fbec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions batch_write_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,23 @@ func (e *MockDynamoDB) BatchWriteItem(input *dynamodb.BatchWriteItemInput) (*dyn

return nil, fmt.Errorf("Batch Write Item Expectation Not Found")
}

// BatchWriteItemWithContext - this func will be invoked when test running matching expectation with actual input
func (e *MockDynamoDB) BatchWriteItemWithContext(ctx aws.Context, input *dynamodb.BatchWriteItemInput, opt ...request.Option) (*dynamodb.BatchWriteItemOutput, error) {
if len(e.dynaMock.BatchWriteItemExpect) > 0 {
x := e.dynaMock.BatchWriteItemExpect[0] //get first element of expectation

if x.input != nil {
if !reflect.DeepEqual(x.input, input.RequestItems) {
return nil, fmt.Errorf("Expect input %+v but found input %+v", x.input, input.RequestItems)
}
}

// delete first element of expectation
e.dynaMock.BatchWriteItemExpect = append(e.dynaMock.BatchWriteItemExpect[:0], e.dynaMock.BatchWriteItemExpect[1:]...)

return x.output, nil
}

return nil, fmt.Errorf("Batch Write Item Expectation Not Found")
}

0 comments on commit 261fbec

Please sign in to comment.