-
Notifications
You must be signed in to change notification settings - Fork 0
/
dummy.go
106 lines (91 loc) · 2.68 KB
/
dummy.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package dummy
import (
"sync/atomic"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/s3"
)
// NewS3API mocks the S3 API parts we use.
func NewS3API(region string, opts ...func(*S3API)) *S3API {
if region == "" {
region = "default-region"
}
d := &S3API{region: aws.String(region)}
for _, opt := range opts {
opt(d)
}
return d
}
// S3API is the API struct.
type S3API struct {
region *string
Cmp *s3.CreateMultipartUploadOutput
CmpCalls int64
CmpErr error
CooErr error
Coo *s3.CopyObjectOutput
Hoo *s3.HeadObjectOutput
HooErr error
Doo *s3.DeleteObjectOutput
DooCalls int64
DooErr error
Upc *s3.UploadPartCopyOutput
UpcErr error
UpcCalls int64
Cmpu *s3.CompleteMultipartUploadOutput
CmpuErr error
CmpuCalls int64
}
// CopyObjectWithContext is a mock method.
func (d *S3API) CopyObjectWithContext(_ aws.Context, in *s3.CopyObjectInput, opts ...request.Option) (*s3.CopyObjectOutput, error) {
if d.CooErr != nil {
return nil, d.CooErr
}
return d.Coo, nil
}
// CreateMultipartUploadWithContext is a mock method.
func (d *S3API) CreateMultipartUploadWithContext(_ aws.Context, in *s3.CreateMultipartUploadInput, ops ...request.Option) (*s3.CreateMultipartUploadOutput, error) {
_ = atomic.AddInt64(&d.CmpCalls, 1)
if d.CmpErr != nil {
return nil, d.CmpErr
}
return d.Cmp, nil
}
// HeadObjectWithContext is a mock method.
func (d *S3API) HeadObjectWithContext(ctx aws.Context, in *s3.HeadObjectInput, opts ...request.Option) (*s3.HeadObjectOutput, error) {
if d.HooErr != nil {
return nil, d.HooErr
}
return d.Hoo, nil
}
// DeleteObjectWithContext is a mock method.
func (d *S3API) DeleteObjectWithContext(ctx aws.Context, in *s3.DeleteObjectInput, opts ...request.Option) (*s3.DeleteObjectOutput, error) {
_ = atomic.AddInt64(&d.DooCalls, 1)
if d.DooErr != nil {
return nil, d.DooErr
}
return d.Doo, nil
}
// UploadPartCopyWithContext is a mock method.
func (d *S3API) UploadPartCopyWithContext(ctx aws.Context, in *s3.UploadPartCopyInput, opts ...request.Option) (*s3.UploadPartCopyOutput, error) {
_ = atomic.AddInt64(&d.UpcCalls, 1)
if d.UpcErr != nil {
return nil, d.UpcErr
}
return d.Upc, nil
}
// CompleteMultipartUploadWithContext is a mock method.
func (d *S3API) CompleteMultipartUploadWithContext(ctx aws.Context, in *s3.CompleteMultipartUploadInput, opts ...request.Option) (*s3.CompleteMultipartUploadOutput, error) {
_ = atomic.AddInt64(&d.CmpuCalls, 1)
if d.CmpuErr != nil {
return nil, d.CmpuErr
}
return d.Cmpu, nil
}
// Region is a mock method.
func (d *S3API) Region() string {
if d.region == nil {
return ""
}
return *d.region
}