lab4: S3-вложения, presigned upload и проверки
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"mtusi-messenger/internal/domain"
|
||||
"mtusi-messenger/internal/service/attachment"
|
||||
|
||||
"github.com/google/uuid"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockAttachmentService creates a new instance of MockAttachmentService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockAttachmentService(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockAttachmentService {
|
||||
if helper, ok := t.(interface{ Helper() }); ok {
|
||||
helper.Helper()
|
||||
}
|
||||
|
||||
mock := &MockAttachmentService{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() {
|
||||
if helper, ok := t.(interface{ Helper() }); ok {
|
||||
helper.Helper()
|
||||
}
|
||||
mock.AssertExpectations(t)
|
||||
})
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockAttachmentService is an autogenerated mock type for the AttachmentService type
|
||||
type MockAttachmentService struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockAttachmentService_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockAttachmentService) EXPECT() *MockAttachmentService_Expecter {
|
||||
return &MockAttachmentService_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Complete provides a mock function for the type MockAttachmentService
|
||||
func (_mock *MockAttachmentService) Complete(ctx context.Context, ownerID uuid.UUID, id uuid.UUID, sha256 string) (domain.Attachment, error) {
|
||||
ret := _mock.Called(ctx, ownerID, id, sha256)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Complete")
|
||||
}
|
||||
|
||||
var r0 domain.Attachment
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, string) (domain.Attachment, error)); ok {
|
||||
return returnFunc(ctx, ownerID, id, sha256)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, string) domain.Attachment); ok {
|
||||
r0 = returnFunc(ctx, ownerID, id, sha256)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.Attachment)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, string) error); ok {
|
||||
r1 = returnFunc(ctx, ownerID, id, sha256)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockAttachmentService_Complete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Complete'
|
||||
type MockAttachmentService_Complete_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Complete is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - ownerID uuid.UUID
|
||||
// - id uuid.UUID
|
||||
// - sha256 string
|
||||
func (_e *MockAttachmentService_Expecter) Complete(ctx any, ownerID any, id any, sha256 any) *MockAttachmentService_Complete_Call {
|
||||
return &MockAttachmentService_Complete_Call{Call: _e.mock.On("Complete", ctx, ownerID, id, sha256)}
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Complete_Call) Run(run func(ctx context.Context, ownerID uuid.UUID, id uuid.UUID, sha256 string)) *MockAttachmentService_Complete_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 uuid.UUID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(uuid.UUID)
|
||||
}
|
||||
var arg2 uuid.UUID
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(uuid.UUID)
|
||||
}
|
||||
var arg3 string
|
||||
if args[3] != nil {
|
||||
arg3 = args[3].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Complete_Call) Return(attachment domain.Attachment, err error) *MockAttachmentService_Complete_Call {
|
||||
_c.Call.Return(attachment, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Complete_Call) RunAndReturn(run func(ctx context.Context, ownerID uuid.UUID, id uuid.UUID, sha256 string) (domain.Attachment, error)) *MockAttachmentService_Complete_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Get provides a mock function for the type MockAttachmentService
|
||||
func (_mock *MockAttachmentService) Get(ctx context.Context, callerID uuid.UUID, id uuid.UUID) (domain.Attachment, error) {
|
||||
ret := _mock.Called(ctx, callerID, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 domain.Attachment
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (domain.Attachment, error)); ok {
|
||||
return returnFunc(ctx, callerID, id)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) domain.Attachment); ok {
|
||||
r0 = returnFunc(ctx, callerID, id)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.Attachment)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok {
|
||||
r1 = returnFunc(ctx, callerID, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockAttachmentService_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
|
||||
type MockAttachmentService_Get_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Get is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - callerID uuid.UUID
|
||||
// - id uuid.UUID
|
||||
func (_e *MockAttachmentService_Expecter) Get(ctx any, callerID any, id any) *MockAttachmentService_Get_Call {
|
||||
return &MockAttachmentService_Get_Call{Call: _e.mock.On("Get", ctx, callerID, id)}
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Get_Call) Run(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID)) *MockAttachmentService_Get_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 uuid.UUID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(uuid.UUID)
|
||||
}
|
||||
var arg2 uuid.UUID
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(uuid.UUID)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Get_Call) Return(attachment domain.Attachment, err error) *MockAttachmentService_Get_Call {
|
||||
_c.Call.Return(attachment, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Get_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID) (domain.Attachment, error)) *MockAttachmentService_Get_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Open provides a mock function for the type MockAttachmentService
|
||||
func (_mock *MockAttachmentService) Open(ctx context.Context, callerID uuid.UUID, id uuid.UUID) (domain.Attachment, io.ReadCloser, error) {
|
||||
ret := _mock.Called(ctx, callerID, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Open")
|
||||
}
|
||||
|
||||
var r0 domain.Attachment
|
||||
var r1 io.ReadCloser
|
||||
var r2 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (domain.Attachment, io.ReadCloser, error)); ok {
|
||||
return returnFunc(ctx, callerID, id)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) domain.Attachment); ok {
|
||||
r0 = returnFunc(ctx, callerID, id)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.Attachment)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) io.ReadCloser); ok {
|
||||
r1 = returnFunc(ctx, callerID, id)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(io.ReadCloser)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(2).(func(context.Context, uuid.UUID, uuid.UUID) error); ok {
|
||||
r2 = returnFunc(ctx, callerID, id)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// MockAttachmentService_Open_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Open'
|
||||
type MockAttachmentService_Open_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Open is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - callerID uuid.UUID
|
||||
// - id uuid.UUID
|
||||
func (_e *MockAttachmentService_Expecter) Open(ctx any, callerID any, id any) *MockAttachmentService_Open_Call {
|
||||
return &MockAttachmentService_Open_Call{Call: _e.mock.On("Open", ctx, callerID, id)}
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Open_Call) Run(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID)) *MockAttachmentService_Open_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 uuid.UUID
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(uuid.UUID)
|
||||
}
|
||||
var arg2 uuid.UUID
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(uuid.UUID)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Open_Call) Return(attachment domain.Attachment, readCloser io.ReadCloser, err error) *MockAttachmentService_Open_Call {
|
||||
_c.Call.Return(attachment, readCloser, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Open_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID) (domain.Attachment, io.ReadCloser, error)) *MockAttachmentService_Open_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Presign provides a mock function for the type MockAttachmentService
|
||||
func (_mock *MockAttachmentService) Presign(ctx context.Context, request domain.PresignRequest) (domain.PresignResult, error) {
|
||||
ret := _mock.Called(ctx, request)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Presign")
|
||||
}
|
||||
|
||||
var r0 domain.PresignResult
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.PresignRequest) (domain.PresignResult, error)); ok {
|
||||
return returnFunc(ctx, request)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.PresignRequest) domain.PresignResult); ok {
|
||||
r0 = returnFunc(ctx, request)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.PresignResult)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.PresignRequest) error); ok {
|
||||
r1 = returnFunc(ctx, request)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockAttachmentService_Presign_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Presign'
|
||||
type MockAttachmentService_Presign_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Presign is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - request domain.PresignRequest
|
||||
func (_e *MockAttachmentService_Expecter) Presign(ctx any, request any) *MockAttachmentService_Presign_Call {
|
||||
return &MockAttachmentService_Presign_Call{Call: _e.mock.On("Presign", ctx, request)}
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Presign_Call) Run(run func(ctx context.Context, request domain.PresignRequest)) *MockAttachmentService_Presign_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 domain.PresignRequest
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(domain.PresignRequest)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Presign_Call) Return(presignResult domain.PresignResult, err error) *MockAttachmentService_Presign_Call {
|
||||
_c.Call.Return(presignResult, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Presign_Call) RunAndReturn(run func(ctx context.Context, request domain.PresignRequest) (domain.PresignResult, error)) *MockAttachmentService_Presign_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Upload provides a mock function for the type MockAttachmentService
|
||||
func (_mock *MockAttachmentService) Upload(ctx context.Context, input attachment.UploadInput) (domain.Attachment, error) {
|
||||
ret := _mock.Called(ctx, input)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Upload")
|
||||
}
|
||||
|
||||
var r0 domain.Attachment
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, attachment.UploadInput) (domain.Attachment, error)); ok {
|
||||
return returnFunc(ctx, input)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, attachment.UploadInput) domain.Attachment); ok {
|
||||
r0 = returnFunc(ctx, input)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.Attachment)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, attachment.UploadInput) error); ok {
|
||||
r1 = returnFunc(ctx, input)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockAttachmentService_Upload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Upload'
|
||||
type MockAttachmentService_Upload_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Upload is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - input attachment.UploadInput
|
||||
func (_e *MockAttachmentService_Expecter) Upload(ctx any, input any) *MockAttachmentService_Upload_Call {
|
||||
return &MockAttachmentService_Upload_Call{Call: _e.mock.On("Upload", ctx, input)}
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Upload_Call) Run(run func(ctx context.Context, input attachment.UploadInput)) *MockAttachmentService_Upload_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 attachment.UploadInput
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(attachment.UploadInput)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Upload_Call) Return(attachment1 domain.Attachment, err error) *MockAttachmentService_Upload_Call {
|
||||
_c.Call.Return(attachment1, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockAttachmentService_Upload_Call) RunAndReturn(run func(ctx context.Context, input attachment.UploadInput) (domain.Attachment, error)) *MockAttachmentService_Upload_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"mtusi-messenger/internal/domain"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockSessionResolver creates a new instance of MockSessionResolver. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockSessionResolver(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockSessionResolver {
|
||||
if helper, ok := t.(interface{ Helper() }); ok {
|
||||
helper.Helper()
|
||||
}
|
||||
|
||||
mock := &MockSessionResolver{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() {
|
||||
if helper, ok := t.(interface{ Helper() }); ok {
|
||||
helper.Helper()
|
||||
}
|
||||
mock.AssertExpectations(t)
|
||||
})
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockSessionResolver is an autogenerated mock type for the SessionResolver type
|
||||
type MockSessionResolver struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockSessionResolver_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockSessionResolver) EXPECT() *MockSessionResolver_Expecter {
|
||||
return &MockSessionResolver_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Resolve provides a mock function for the type MockSessionResolver
|
||||
func (_mock *MockSessionResolver) Resolve(ctx context.Context, token string) (domain.User, error) {
|
||||
ret := _mock.Called(ctx, token)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Resolve")
|
||||
}
|
||||
|
||||
var r0 domain.User
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string) (domain.User, error)); ok {
|
||||
return returnFunc(ctx, token)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string) domain.User); ok {
|
||||
r0 = returnFunc(ctx, token)
|
||||
} else {
|
||||
r0 = ret.Get(0).(domain.User)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = returnFunc(ctx, token)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockSessionResolver_Resolve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Resolve'
|
||||
type MockSessionResolver_Resolve_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Resolve is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - token string
|
||||
func (_e *MockSessionResolver_Expecter) Resolve(ctx any, token any) *MockSessionResolver_Resolve_Call {
|
||||
return &MockSessionResolver_Resolve_Call{Call: _e.mock.On("Resolve", ctx, token)}
|
||||
}
|
||||
|
||||
func (_c *MockSessionResolver_Resolve_Call) Run(run func(ctx context.Context, token string)) *MockSessionResolver_Resolve_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSessionResolver_Resolve_Call) Return(user domain.User, err error) *MockSessionResolver_Resolve_Call {
|
||||
_c.Call.Return(user, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSessionResolver_Resolve_Call) RunAndReturn(run func(ctx context.Context, token string) (domain.User, error)) *MockSessionResolver_Resolve_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
Reference in New Issue
Block a user