-
Notifications
You must be signed in to change notification settings - Fork 1
/
s3-sdk.go
516 lines (479 loc) · 16.6 KB
/
s3-sdk.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package mock
import (
v2 "github.com/ONSdigital/dp-s3/v2"
s3 "github.com/aws/aws-sdk-go/service/s3"
"sync"
)
// Ensure, that S3SDKClientMock does implement v2.S3SDKClient.
// If this is not the case, regenerate this file with moq.
var _ v2.S3SDKClient = &S3SDKClientMock{}
// S3SDKClientMock is a mock implementation of v2.S3SDKClient.
//
// func TestSomethingThatUsesS3SDKClient(t *testing.T) {
//
// // make and configure a mocked v2.S3SDKClient
// mockedS3SDKClient := &S3SDKClientMock{
// CompleteMultipartUploadFunc: func(in *s3.CompleteMultipartUploadInput) (*s3.CompleteMultipartUploadOutput, error) {
// panic("mock out the CompleteMultipartUpload method")
// },
// CreateMultipartUploadFunc: func(in *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error) {
// panic("mock out the CreateMultipartUpload method")
// },
// GetBucketPolicyFunc: func(in *s3.GetBucketPolicyInput) (*s3.GetBucketPolicyOutput, error) {
// panic("mock out the GetBucketPolicy method")
// },
// GetObjectFunc: func(in *s3.GetObjectInput) (*s3.GetObjectOutput, error) {
// panic("mock out the GetObject method")
// },
// HeadBucketFunc: func(in *s3.HeadBucketInput) (*s3.HeadBucketOutput, error) {
// panic("mock out the HeadBucket method")
// },
// HeadObjectFunc: func(in *s3.HeadObjectInput) (*s3.HeadObjectOutput, error) {
// panic("mock out the HeadObject method")
// },
// ListMultipartUploadsFunc: func(in *s3.ListMultipartUploadsInput) (*s3.ListMultipartUploadsOutput, error) {
// panic("mock out the ListMultipartUploads method")
// },
// ListObjectsFunc: func(in *s3.ListObjectsInput) (*s3.ListObjectsOutput, error) {
// panic("mock out the ListObjects method")
// },
// ListPartsFunc: func(in *s3.ListPartsInput) (*s3.ListPartsOutput, error) {
// panic("mock out the ListParts method")
// },
// PutBucketPolicyFunc: func(in *s3.PutBucketPolicyInput) (*s3.PutBucketPolicyOutput, error) {
// panic("mock out the PutBucketPolicy method")
// },
// UploadPartFunc: func(in *s3.UploadPartInput) (*s3.UploadPartOutput, error) {
// panic("mock out the UploadPart method")
// },
// }
//
// // use mockedS3SDKClient in code that requires v2.S3SDKClient
// // and then make assertions.
//
// }
type S3SDKClientMock struct {
// CompleteMultipartUploadFunc mocks the CompleteMultipartUpload method.
CompleteMultipartUploadFunc func(in *s3.CompleteMultipartUploadInput) (*s3.CompleteMultipartUploadOutput, error)
// CreateMultipartUploadFunc mocks the CreateMultipartUpload method.
CreateMultipartUploadFunc func(in *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error)
// GetBucketPolicyFunc mocks the GetBucketPolicy method.
GetBucketPolicyFunc func(in *s3.GetBucketPolicyInput) (*s3.GetBucketPolicyOutput, error)
// GetObjectFunc mocks the GetObject method.
GetObjectFunc func(in *s3.GetObjectInput) (*s3.GetObjectOutput, error)
// HeadBucketFunc mocks the HeadBucket method.
HeadBucketFunc func(in *s3.HeadBucketInput) (*s3.HeadBucketOutput, error)
// HeadObjectFunc mocks the HeadObject method.
HeadObjectFunc func(in *s3.HeadObjectInput) (*s3.HeadObjectOutput, error)
// ListMultipartUploadsFunc mocks the ListMultipartUploads method.
ListMultipartUploadsFunc func(in *s3.ListMultipartUploadsInput) (*s3.ListMultipartUploadsOutput, error)
// ListObjectsFunc mocks the ListObjects method.
ListObjectsFunc func(in *s3.ListObjectsInput) (*s3.ListObjectsOutput, error)
// ListPartsFunc mocks the ListParts method.
ListPartsFunc func(in *s3.ListPartsInput) (*s3.ListPartsOutput, error)
// PutBucketPolicyFunc mocks the PutBucketPolicy method.
PutBucketPolicyFunc func(in *s3.PutBucketPolicyInput) (*s3.PutBucketPolicyOutput, error)
// UploadPartFunc mocks the UploadPart method.
UploadPartFunc func(in *s3.UploadPartInput) (*s3.UploadPartOutput, error)
// calls tracks calls to the methods.
calls struct {
// CompleteMultipartUpload holds details about calls to the CompleteMultipartUpload method.
CompleteMultipartUpload []struct {
// In is the in argument value.
In *s3.CompleteMultipartUploadInput
}
// CreateMultipartUpload holds details about calls to the CreateMultipartUpload method.
CreateMultipartUpload []struct {
// In is the in argument value.
In *s3.CreateMultipartUploadInput
}
// GetBucketPolicy holds details about calls to the GetBucketPolicy method.
GetBucketPolicy []struct {
// In is the in argument value.
In *s3.GetBucketPolicyInput
}
// GetObject holds details about calls to the GetObject method.
GetObject []struct {
// In is the in argument value.
In *s3.GetObjectInput
}
// HeadBucket holds details about calls to the HeadBucket method.
HeadBucket []struct {
// In is the in argument value.
In *s3.HeadBucketInput
}
// HeadObject holds details about calls to the HeadObject method.
HeadObject []struct {
// In is the in argument value.
In *s3.HeadObjectInput
}
// ListMultipartUploads holds details about calls to the ListMultipartUploads method.
ListMultipartUploads []struct {
// In is the in argument value.
In *s3.ListMultipartUploadsInput
}
// ListObjects holds details about calls to the ListObjects method.
ListObjects []struct {
// In is the in argument value.
In *s3.ListObjectsInput
}
// ListParts holds details about calls to the ListParts method.
ListParts []struct {
// In is the in argument value.
In *s3.ListPartsInput
}
// PutBucketPolicy holds details about calls to the PutBucketPolicy method.
PutBucketPolicy []struct {
// In is the in argument value.
In *s3.PutBucketPolicyInput
}
// UploadPart holds details about calls to the UploadPart method.
UploadPart []struct {
// In is the in argument value.
In *s3.UploadPartInput
}
}
lockCompleteMultipartUpload sync.RWMutex
lockCreateMultipartUpload sync.RWMutex
lockGetBucketPolicy sync.RWMutex
lockGetObject sync.RWMutex
lockHeadBucket sync.RWMutex
lockHeadObject sync.RWMutex
lockListMultipartUploads sync.RWMutex
lockListObjects sync.RWMutex
lockListParts sync.RWMutex
lockPutBucketPolicy sync.RWMutex
lockUploadPart sync.RWMutex
}
// CompleteMultipartUpload calls CompleteMultipartUploadFunc.
func (mock *S3SDKClientMock) CompleteMultipartUpload(in *s3.CompleteMultipartUploadInput) (*s3.CompleteMultipartUploadOutput, error) {
if mock.CompleteMultipartUploadFunc == nil {
panic("S3SDKClientMock.CompleteMultipartUploadFunc: method is nil but S3SDKClient.CompleteMultipartUpload was just called")
}
callInfo := struct {
In *s3.CompleteMultipartUploadInput
}{
In: in,
}
mock.lockCompleteMultipartUpload.Lock()
mock.calls.CompleteMultipartUpload = append(mock.calls.CompleteMultipartUpload, callInfo)
mock.lockCompleteMultipartUpload.Unlock()
return mock.CompleteMultipartUploadFunc(in)
}
// CompleteMultipartUploadCalls gets all the calls that were made to CompleteMultipartUpload.
// Check the length with:
//
// len(mockedS3SDKClient.CompleteMultipartUploadCalls())
func (mock *S3SDKClientMock) CompleteMultipartUploadCalls() []struct {
In *s3.CompleteMultipartUploadInput
} {
var calls []struct {
In *s3.CompleteMultipartUploadInput
}
mock.lockCompleteMultipartUpload.RLock()
calls = mock.calls.CompleteMultipartUpload
mock.lockCompleteMultipartUpload.RUnlock()
return calls
}
// CreateMultipartUpload calls CreateMultipartUploadFunc.
func (mock *S3SDKClientMock) CreateMultipartUpload(in *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error) {
if mock.CreateMultipartUploadFunc == nil {
panic("S3SDKClientMock.CreateMultipartUploadFunc: method is nil but S3SDKClient.CreateMultipartUpload was just called")
}
callInfo := struct {
In *s3.CreateMultipartUploadInput
}{
In: in,
}
mock.lockCreateMultipartUpload.Lock()
mock.calls.CreateMultipartUpload = append(mock.calls.CreateMultipartUpload, callInfo)
mock.lockCreateMultipartUpload.Unlock()
return mock.CreateMultipartUploadFunc(in)
}
// CreateMultipartUploadCalls gets all the calls that were made to CreateMultipartUpload.
// Check the length with:
//
// len(mockedS3SDKClient.CreateMultipartUploadCalls())
func (mock *S3SDKClientMock) CreateMultipartUploadCalls() []struct {
In *s3.CreateMultipartUploadInput
} {
var calls []struct {
In *s3.CreateMultipartUploadInput
}
mock.lockCreateMultipartUpload.RLock()
calls = mock.calls.CreateMultipartUpload
mock.lockCreateMultipartUpload.RUnlock()
return calls
}
// GetBucketPolicy calls GetBucketPolicyFunc.
func (mock *S3SDKClientMock) GetBucketPolicy(in *s3.GetBucketPolicyInput) (*s3.GetBucketPolicyOutput, error) {
if mock.GetBucketPolicyFunc == nil {
panic("S3SDKClientMock.GetBucketPolicyFunc: method is nil but S3SDKClient.GetBucketPolicy was just called")
}
callInfo := struct {
In *s3.GetBucketPolicyInput
}{
In: in,
}
mock.lockGetBucketPolicy.Lock()
mock.calls.GetBucketPolicy = append(mock.calls.GetBucketPolicy, callInfo)
mock.lockGetBucketPolicy.Unlock()
return mock.GetBucketPolicyFunc(in)
}
// GetBucketPolicyCalls gets all the calls that were made to GetBucketPolicy.
// Check the length with:
//
// len(mockedS3SDKClient.GetBucketPolicyCalls())
func (mock *S3SDKClientMock) GetBucketPolicyCalls() []struct {
In *s3.GetBucketPolicyInput
} {
var calls []struct {
In *s3.GetBucketPolicyInput
}
mock.lockGetBucketPolicy.RLock()
calls = mock.calls.GetBucketPolicy
mock.lockGetBucketPolicy.RUnlock()
return calls
}
// GetObject calls GetObjectFunc.
func (mock *S3SDKClientMock) GetObject(in *s3.GetObjectInput) (*s3.GetObjectOutput, error) {
if mock.GetObjectFunc == nil {
panic("S3SDKClientMock.GetObjectFunc: method is nil but S3SDKClient.GetObject was just called")
}
callInfo := struct {
In *s3.GetObjectInput
}{
In: in,
}
mock.lockGetObject.Lock()
mock.calls.GetObject = append(mock.calls.GetObject, callInfo)
mock.lockGetObject.Unlock()
return mock.GetObjectFunc(in)
}
// GetObjectCalls gets all the calls that were made to GetObject.
// Check the length with:
//
// len(mockedS3SDKClient.GetObjectCalls())
func (mock *S3SDKClientMock) GetObjectCalls() []struct {
In *s3.GetObjectInput
} {
var calls []struct {
In *s3.GetObjectInput
}
mock.lockGetObject.RLock()
calls = mock.calls.GetObject
mock.lockGetObject.RUnlock()
return calls
}
// HeadBucket calls HeadBucketFunc.
func (mock *S3SDKClientMock) HeadBucket(in *s3.HeadBucketInput) (*s3.HeadBucketOutput, error) {
if mock.HeadBucketFunc == nil {
panic("S3SDKClientMock.HeadBucketFunc: method is nil but S3SDKClient.HeadBucket was just called")
}
callInfo := struct {
In *s3.HeadBucketInput
}{
In: in,
}
mock.lockHeadBucket.Lock()
mock.calls.HeadBucket = append(mock.calls.HeadBucket, callInfo)
mock.lockHeadBucket.Unlock()
return mock.HeadBucketFunc(in)
}
// HeadBucketCalls gets all the calls that were made to HeadBucket.
// Check the length with:
//
// len(mockedS3SDKClient.HeadBucketCalls())
func (mock *S3SDKClientMock) HeadBucketCalls() []struct {
In *s3.HeadBucketInput
} {
var calls []struct {
In *s3.HeadBucketInput
}
mock.lockHeadBucket.RLock()
calls = mock.calls.HeadBucket
mock.lockHeadBucket.RUnlock()
return calls
}
// HeadObject calls HeadObjectFunc.
func (mock *S3SDKClientMock) HeadObject(in *s3.HeadObjectInput) (*s3.HeadObjectOutput, error) {
if mock.HeadObjectFunc == nil {
panic("S3SDKClientMock.HeadObjectFunc: method is nil but S3SDKClient.HeadObject was just called")
}
callInfo := struct {
In *s3.HeadObjectInput
}{
In: in,
}
mock.lockHeadObject.Lock()
mock.calls.HeadObject = append(mock.calls.HeadObject, callInfo)
mock.lockHeadObject.Unlock()
return mock.HeadObjectFunc(in)
}
// HeadObjectCalls gets all the calls that were made to HeadObject.
// Check the length with:
//
// len(mockedS3SDKClient.HeadObjectCalls())
func (mock *S3SDKClientMock) HeadObjectCalls() []struct {
In *s3.HeadObjectInput
} {
var calls []struct {
In *s3.HeadObjectInput
}
mock.lockHeadObject.RLock()
calls = mock.calls.HeadObject
mock.lockHeadObject.RUnlock()
return calls
}
// ListMultipartUploads calls ListMultipartUploadsFunc.
func (mock *S3SDKClientMock) ListMultipartUploads(in *s3.ListMultipartUploadsInput) (*s3.ListMultipartUploadsOutput, error) {
if mock.ListMultipartUploadsFunc == nil {
panic("S3SDKClientMock.ListMultipartUploadsFunc: method is nil but S3SDKClient.ListMultipartUploads was just called")
}
callInfo := struct {
In *s3.ListMultipartUploadsInput
}{
In: in,
}
mock.lockListMultipartUploads.Lock()
mock.calls.ListMultipartUploads = append(mock.calls.ListMultipartUploads, callInfo)
mock.lockListMultipartUploads.Unlock()
return mock.ListMultipartUploadsFunc(in)
}
// ListMultipartUploadsCalls gets all the calls that were made to ListMultipartUploads.
// Check the length with:
//
// len(mockedS3SDKClient.ListMultipartUploadsCalls())
func (mock *S3SDKClientMock) ListMultipartUploadsCalls() []struct {
In *s3.ListMultipartUploadsInput
} {
var calls []struct {
In *s3.ListMultipartUploadsInput
}
mock.lockListMultipartUploads.RLock()
calls = mock.calls.ListMultipartUploads
mock.lockListMultipartUploads.RUnlock()
return calls
}
// ListObjects calls ListObjectsFunc.
func (mock *S3SDKClientMock) ListObjects(in *s3.ListObjectsInput) (*s3.ListObjectsOutput, error) {
if mock.ListObjectsFunc == nil {
panic("S3SDKClientMock.ListObjectsFunc: method is nil but S3SDKClient.ListObjects was just called")
}
callInfo := struct {
In *s3.ListObjectsInput
}{
In: in,
}
mock.lockListObjects.Lock()
mock.calls.ListObjects = append(mock.calls.ListObjects, callInfo)
mock.lockListObjects.Unlock()
return mock.ListObjectsFunc(in)
}
// ListObjectsCalls gets all the calls that were made to ListObjects.
// Check the length with:
//
// len(mockedS3SDKClient.ListObjectsCalls())
func (mock *S3SDKClientMock) ListObjectsCalls() []struct {
In *s3.ListObjectsInput
} {
var calls []struct {
In *s3.ListObjectsInput
}
mock.lockListObjects.RLock()
calls = mock.calls.ListObjects
mock.lockListObjects.RUnlock()
return calls
}
// ListParts calls ListPartsFunc.
func (mock *S3SDKClientMock) ListParts(in *s3.ListPartsInput) (*s3.ListPartsOutput, error) {
if mock.ListPartsFunc == nil {
panic("S3SDKClientMock.ListPartsFunc: method is nil but S3SDKClient.ListParts was just called")
}
callInfo := struct {
In *s3.ListPartsInput
}{
In: in,
}
mock.lockListParts.Lock()
mock.calls.ListParts = append(mock.calls.ListParts, callInfo)
mock.lockListParts.Unlock()
return mock.ListPartsFunc(in)
}
// ListPartsCalls gets all the calls that were made to ListParts.
// Check the length with:
//
// len(mockedS3SDKClient.ListPartsCalls())
func (mock *S3SDKClientMock) ListPartsCalls() []struct {
In *s3.ListPartsInput
} {
var calls []struct {
In *s3.ListPartsInput
}
mock.lockListParts.RLock()
calls = mock.calls.ListParts
mock.lockListParts.RUnlock()
return calls
}
// PutBucketPolicy calls PutBucketPolicyFunc.
func (mock *S3SDKClientMock) PutBucketPolicy(in *s3.PutBucketPolicyInput) (*s3.PutBucketPolicyOutput, error) {
if mock.PutBucketPolicyFunc == nil {
panic("S3SDKClientMock.PutBucketPolicyFunc: method is nil but S3SDKClient.PutBucketPolicy was just called")
}
callInfo := struct {
In *s3.PutBucketPolicyInput
}{
In: in,
}
mock.lockPutBucketPolicy.Lock()
mock.calls.PutBucketPolicy = append(mock.calls.PutBucketPolicy, callInfo)
mock.lockPutBucketPolicy.Unlock()
return mock.PutBucketPolicyFunc(in)
}
// PutBucketPolicyCalls gets all the calls that were made to PutBucketPolicy.
// Check the length with:
//
// len(mockedS3SDKClient.PutBucketPolicyCalls())
func (mock *S3SDKClientMock) PutBucketPolicyCalls() []struct {
In *s3.PutBucketPolicyInput
} {
var calls []struct {
In *s3.PutBucketPolicyInput
}
mock.lockPutBucketPolicy.RLock()
calls = mock.calls.PutBucketPolicy
mock.lockPutBucketPolicy.RUnlock()
return calls
}
// UploadPart calls UploadPartFunc.
func (mock *S3SDKClientMock) UploadPart(in *s3.UploadPartInput) (*s3.UploadPartOutput, error) {
if mock.UploadPartFunc == nil {
panic("S3SDKClientMock.UploadPartFunc: method is nil but S3SDKClient.UploadPart was just called")
}
callInfo := struct {
In *s3.UploadPartInput
}{
In: in,
}
mock.lockUploadPart.Lock()
mock.calls.UploadPart = append(mock.calls.UploadPart, callInfo)
mock.lockUploadPart.Unlock()
return mock.UploadPartFunc(in)
}
// UploadPartCalls gets all the calls that were made to UploadPart.
// Check the length with:
//
// len(mockedS3SDKClient.UploadPartCalls())
func (mock *S3SDKClientMock) UploadPartCalls() []struct {
In *s3.UploadPartInput
} {
var calls []struct {
In *s3.UploadPartInput
}
mock.lockUploadPart.RLock()
calls = mock.calls.UploadPart
mock.lockUploadPart.RUnlock()
return calls
}