/
batch_delete_with_client.go
45 lines (39 loc) · 1.25 KB
/
batch_delete_with_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package test
import (
awsSdkGoAws "github.com/aws/aws-sdk-go/aws"
awsSdkGoServiceS3S3manager "github.com/aws/aws-sdk-go/service/s3/s3manager"
)
type BatchDeleteWithClient struct {
DeleteInvocations int
DeleteInputs []awsSdkGoServiceS3S3manager.BatchDeleteIterator
DeleteStub func(ctx awsSdkGoAws.Context, batchDeleteIterator awsSdkGoServiceS3S3manager.BatchDeleteIterator) error
DeleteOutputs []error
DeleteOutput *error
}
func NewBatchDeleteWithClient() *BatchDeleteWithClient {
return &BatchDeleteWithClient{}
}
func (b *BatchDeleteWithClient) Delete(ctx awsSdkGoAws.Context, batchDeleteIterator awsSdkGoServiceS3S3manager.BatchDeleteIterator) error {
b.DeleteInvocations++
b.DeleteInputs = append(b.DeleteInputs, batchDeleteIterator)
if b.DeleteStub != nil {
return b.DeleteStub(ctx, batchDeleteIterator)
}
if len(b.DeleteOutputs) > 0 {
output := b.DeleteOutputs[0]
b.DeleteOutputs = b.DeleteOutputs[1:]
return output
}
if b.DeleteOutput != nil {
return *b.DeleteOutput
}
panic("Delete has no output")
}
func (b *BatchDeleteWithClient) SetDeleteOutput(output error) {
b.DeleteOutput = &output
}
func (b *BatchDeleteWithClient) AssertOutputsEmpty() {
if len(b.DeleteOutputs) > 0 {
panic("DeleteOutputs is not empty")
}
}