Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
- Loading branch information
Showing
3 changed files
with
293 additions
and
208 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
internal/db/storage/blob/s3/sdk/s3/s3manager/s3manager_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package s3manager | ||
|
||
type Mock struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package writer | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/vdaas/vald/internal/db/storage/blob/s3/sdk/s3/s3iface" | ||
"github.com/vdaas/vald/internal/db/storage/blob/s3/sdk/s3/s3manager" | ||
) | ||
|
||
// S3Manager represents mock of s3manager.S3Manager. | ||
type MockS3Manager struct { | ||
NewUploaderWithClientFunc func(s3iface.S3API, ...func(*s3manager.Uploader)) s3manager.UploadClient | ||
} | ||
|
||
// NewUploaderWithClient calls NewUNewUploaderWithClientFunc. | ||
func (m *MockS3Manager) NewUploaderWithClient(svc s3iface.S3API, opts ...func(*s3manager.Uploader)) s3manager.UploadClient { | ||
return m.NewUploaderWithClientFunc(svc, opts...) | ||
} | ||
|
||
type MockUploadClient struct { | ||
UploadWithContextFunc func(aws.Context, *s3manager.UploadInput, ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error) | ||
} | ||
|
||
func (m *MockUploadClient) UploadWithContext(ctx aws.Context, input *s3manager.UploadInput, opts ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error) { | ||
return m.UploadWithContextFunc(ctx, input, opts...) | ||
} | ||
|
||
// MockWriteCloser represents mock of io.WriteCloser. | ||
type MockWriteCloser struct { | ||
WriteFunc func(p []byte) (n int, err error) | ||
CloseFunc func() error | ||
} | ||
|
||
func (m *MockWriteCloser) Write(p []byte) (n int, err error) { | ||
return m.WriteFunc(p) | ||
} | ||
|
||
func (m *MockWriteCloser) Close() error { | ||
return m.CloseFunc() | ||
} | ||
|
||
// MockGroup represents mock of errorgroup.Group. | ||
type MockGroup struct { | ||
GoFunc func(func() error) | ||
LimitationFunc func(int) | ||
WaitFunc func() error | ||
} | ||
|
||
func (m *MockGroup) Go(f func() error) { | ||
m.GoFunc(f) | ||
} | ||
|
||
func (m *MockGroup) Limitation(n int) { | ||
m.LimitationFunc(n) | ||
} | ||
|
||
func (m *MockGroup) Wait() error { | ||
return m.WaitFunc() | ||
} |
Oops, something went wrong.