lab7: безопасность, mTLS, OpenBao и PKI lifecycle
Application / Go invariants and static checks (pull_request) Canceled after 0s
Application / Lab7 verified TLS and retained features (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Vladislav Kunetskiy
2026-11-10 14:39:57 +03:00
parent 20afc2c790
commit 1b6e96ccc0
570 changed files with 298308 additions and 137 deletions
@@ -0,0 +1,425 @@
// 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
}
// OpenVariant provides a mock function for the type MockAttachmentService
func (_mock *MockAttachmentService) OpenVariant(ctx context.Context, callerID uuid.UUID, id uuid.UUID, name domain.VariantName) (domain.Attachment, domain.Variant, io.ReadCloser, error) {
ret := _mock.Called(ctx, callerID, id, name)
if len(ret) == 0 {
panic("no return value specified for OpenVariant")
}
var r0 domain.Attachment
var r1 domain.Variant
var r2 io.ReadCloser
var r3 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, domain.VariantName) (domain.Attachment, domain.Variant, io.ReadCloser, error)); ok {
return returnFunc(ctx, callerID, id, name)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, domain.VariantName) domain.Attachment); ok {
r0 = returnFunc(ctx, callerID, id, name)
} else {
r0 = ret.Get(0).(domain.Attachment)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, domain.VariantName) domain.Variant); ok {
r1 = returnFunc(ctx, callerID, id, name)
} else {
r1 = ret.Get(1).(domain.Variant)
}
if returnFunc, ok := ret.Get(2).(func(context.Context, uuid.UUID, uuid.UUID, domain.VariantName) io.ReadCloser); ok {
r2 = returnFunc(ctx, callerID, id, name)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).(io.ReadCloser)
}
}
if returnFunc, ok := ret.Get(3).(func(context.Context, uuid.UUID, uuid.UUID, domain.VariantName) error); ok {
r3 = returnFunc(ctx, callerID, id, name)
} else {
r3 = ret.Error(3)
}
return r0, r1, r2, r3
}
// MockAttachmentService_OpenVariant_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpenVariant'
type MockAttachmentService_OpenVariant_Call struct {
*mock.Call
}
// OpenVariant is a helper method to define mock.On call
// - ctx context.Context
// - callerID uuid.UUID
// - id uuid.UUID
// - name domain.VariantName
func (_e *MockAttachmentService_Expecter) OpenVariant(ctx any, callerID any, id any, name any) *MockAttachmentService_OpenVariant_Call {
return &MockAttachmentService_OpenVariant_Call{Call: _e.mock.On("OpenVariant", ctx, callerID, id, name)}
}
func (_c *MockAttachmentService_OpenVariant_Call) Run(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID, name domain.VariantName)) *MockAttachmentService_OpenVariant_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 domain.VariantName
if args[3] != nil {
arg3 = args[3].(domain.VariantName)
}
run(
arg0,
arg1,
arg2,
arg3,
)
})
return _c
}
func (_c *MockAttachmentService_OpenVariant_Call) Return(attachment domain.Attachment, variant domain.Variant, readCloser io.ReadCloser, err error) *MockAttachmentService_OpenVariant_Call {
_c.Call.Return(attachment, variant, readCloser, err)
return _c
}
func (_c *MockAttachmentService_OpenVariant_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, id uuid.UUID, name domain.VariantName) (domain.Attachment, domain.Variant, io.ReadCloser, error)) *MockAttachmentService_OpenVariant_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,265 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockChatService creates a new instance of MockChatService. 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 NewMockChatService(t interface {
mock.TestingT
Cleanup(func())
}) *MockChatService {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockChatService{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockChatService is an autogenerated mock type for the ChatService type
type MockChatService struct {
mock.Mock
}
type MockChatService_Expecter struct {
mock *mock.Mock
}
func (_m *MockChatService) EXPECT() *MockChatService_Expecter {
return &MockChatService_Expecter{mock: &_m.Mock}
}
// Create provides a mock function for the type MockChatService
func (_mock *MockChatService) Create(ctx context.Context, draft domain.ChatDraft) (domain.Chat, error) {
ret := _mock.Called(ctx, draft)
if len(ret) == 0 {
panic("no return value specified for Create")
}
var r0 domain.Chat
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.ChatDraft) (domain.Chat, error)); ok {
return returnFunc(ctx, draft)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.ChatDraft) domain.Chat); ok {
r0 = returnFunc(ctx, draft)
} else {
r0 = ret.Get(0).(domain.Chat)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.ChatDraft) error); ok {
r1 = returnFunc(ctx, draft)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockChatService_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'
type MockChatService_Create_Call struct {
*mock.Call
}
// Create is a helper method to define mock.On call
// - ctx context.Context
// - draft domain.ChatDraft
func (_e *MockChatService_Expecter) Create(ctx any, draft any) *MockChatService_Create_Call {
return &MockChatService_Create_Call{Call: _e.mock.On("Create", ctx, draft)}
}
func (_c *MockChatService_Create_Call) Run(run func(ctx context.Context, draft domain.ChatDraft)) *MockChatService_Create_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 domain.ChatDraft
if args[1] != nil {
arg1 = args[1].(domain.ChatDraft)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockChatService_Create_Call) Return(chat domain.Chat, err error) *MockChatService_Create_Call {
_c.Call.Return(chat, err)
return _c
}
func (_c *MockChatService_Create_Call) RunAndReturn(run func(ctx context.Context, draft domain.ChatDraft) (domain.Chat, error)) *MockChatService_Create_Call {
_c.Call.Return(run)
return _c
}
// Get provides a mock function for the type MockChatService
func (_mock *MockChatService) Get(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID) (domain.Chat, error) {
ret := _mock.Called(ctx, callerID, chatID)
if len(ret) == 0 {
panic("no return value specified for Get")
}
var r0 domain.Chat
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (domain.Chat, error)); ok {
return returnFunc(ctx, callerID, chatID)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) domain.Chat); ok {
r0 = returnFunc(ctx, callerID, chatID)
} else {
r0 = ret.Get(0).(domain.Chat)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok {
r1 = returnFunc(ctx, callerID, chatID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockChatService_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
type MockChatService_Get_Call struct {
*mock.Call
}
// Get is a helper method to define mock.On call
// - ctx context.Context
// - callerID uuid.UUID
// - chatID uuid.UUID
func (_e *MockChatService_Expecter) Get(ctx any, callerID any, chatID any) *MockChatService_Get_Call {
return &MockChatService_Get_Call{Call: _e.mock.On("Get", ctx, callerID, chatID)}
}
func (_c *MockChatService_Get_Call) Run(run func(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID)) *MockChatService_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 *MockChatService_Get_Call) Return(chat domain.Chat, err error) *MockChatService_Get_Call {
_c.Call.Return(chat, err)
return _c
}
func (_c *MockChatService_Get_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID) (domain.Chat, error)) *MockChatService_Get_Call {
_c.Call.Return(run)
return _c
}
// List provides a mock function for the type MockChatService
func (_mock *MockChatService) List(ctx context.Context, callerID uuid.UUID, after *domain.Cursor, limit int) (domain.Page[domain.Chat], error) {
ret := _mock.Called(ctx, callerID, after, limit)
if len(ret) == 0 {
panic("no return value specified for List")
}
var r0 domain.Page[domain.Chat]
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, *domain.Cursor, int) (domain.Page[domain.Chat], error)); ok {
return returnFunc(ctx, callerID, after, limit)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, *domain.Cursor, int) domain.Page[domain.Chat]); ok {
r0 = returnFunc(ctx, callerID, after, limit)
} else {
r0 = ret.Get(0).(domain.Page[domain.Chat])
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, *domain.Cursor, int) error); ok {
r1 = returnFunc(ctx, callerID, after, limit)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockChatService_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'
type MockChatService_List_Call struct {
*mock.Call
}
// List is a helper method to define mock.On call
// - ctx context.Context
// - callerID uuid.UUID
// - after *domain.Cursor
// - limit int
func (_e *MockChatService_Expecter) List(ctx any, callerID any, after any, limit any) *MockChatService_List_Call {
return &MockChatService_List_Call{Call: _e.mock.On("List", ctx, callerID, after, limit)}
}
func (_c *MockChatService_List_Call) Run(run func(ctx context.Context, callerID uuid.UUID, after *domain.Cursor, limit int)) *MockChatService_List_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 *domain.Cursor
if args[2] != nil {
arg2 = args[2].(*domain.Cursor)
}
var arg3 int
if args[3] != nil {
arg3 = args[3].(int)
}
run(
arg0,
arg1,
arg2,
arg3,
)
})
return _c
}
func (_c *MockChatService_List_Call) Return(page domain.Page[domain.Chat], err error) *MockChatService_List_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockChatService_List_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, after *domain.Cursor, limit int) (domain.Page[domain.Chat], error)) *MockChatService_List_Call {
_c.Call.Return(run)
return _c
}
@@ -0,0 +1,98 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
mock "github.com/stretchr/testify/mock"
)
// NewMockHealthChecker creates a new instance of MockHealthChecker. 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 NewMockHealthChecker(t interface {
mock.TestingT
Cleanup(func())
}) *MockHealthChecker {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockHealthChecker{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockHealthChecker is an autogenerated mock type for the HealthChecker type
type MockHealthChecker struct {
mock.Mock
}
type MockHealthChecker_Expecter struct {
mock *mock.Mock
}
func (_m *MockHealthChecker) EXPECT() *MockHealthChecker_Expecter {
return &MockHealthChecker_Expecter{mock: &_m.Mock}
}
// Ping provides a mock function for the type MockHealthChecker
func (_mock *MockHealthChecker) Ping(ctx context.Context) error {
ret := _mock.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Ping")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = returnFunc(ctx)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockHealthChecker_Ping_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ping'
type MockHealthChecker_Ping_Call struct {
*mock.Call
}
// Ping is a helper method to define mock.On call
// - ctx context.Context
func (_e *MockHealthChecker_Expecter) Ping(ctx any) *MockHealthChecker_Ping_Call {
return &MockHealthChecker_Ping_Call{Call: _e.mock.On("Ping", ctx)}
}
func (_c *MockHealthChecker_Ping_Call) Run(run func(ctx context.Context)) *MockHealthChecker_Ping_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
run(
arg0,
)
})
return _c
}
func (_c *MockHealthChecker_Ping_Call) Return(err error) *MockHealthChecker_Ping_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockHealthChecker_Ping_Call) RunAndReturn(run func(ctx context.Context) error) *MockHealthChecker_Ping_Call {
_c.Call.Return(run)
return _c
}
@@ -0,0 +1,199 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockMessageService creates a new instance of MockMessageService. 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 NewMockMessageService(t interface {
mock.TestingT
Cleanup(func())
}) *MockMessageService {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockMessageService{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockMessageService is an autogenerated mock type for the MessageService type
type MockMessageService struct {
mock.Mock
}
type MockMessageService_Expecter struct {
mock *mock.Mock
}
func (_m *MockMessageService) EXPECT() *MockMessageService_Expecter {
return &MockMessageService_Expecter{mock: &_m.Mock}
}
// History provides a mock function for the type MockMessageService
func (_mock *MockMessageService) History(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID, after *domain.Cursor, limit int) (domain.Page[domain.Message], error) {
ret := _mock.Called(ctx, callerID, chatID, after, limit)
if len(ret) == 0 {
panic("no return value specified for History")
}
var r0 domain.Page[domain.Message]
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, *domain.Cursor, int) (domain.Page[domain.Message], error)); ok {
return returnFunc(ctx, callerID, chatID, after, limit)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, *domain.Cursor, int) domain.Page[domain.Message]); ok {
r0 = returnFunc(ctx, callerID, chatID, after, limit)
} else {
r0 = ret.Get(0).(domain.Page[domain.Message])
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, *domain.Cursor, int) error); ok {
r1 = returnFunc(ctx, callerID, chatID, after, limit)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockMessageService_History_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'History'
type MockMessageService_History_Call struct {
*mock.Call
}
// History is a helper method to define mock.On call
// - ctx context.Context
// - callerID uuid.UUID
// - chatID uuid.UUID
// - after *domain.Cursor
// - limit int
func (_e *MockMessageService_Expecter) History(ctx any, callerID any, chatID any, after any, limit any) *MockMessageService_History_Call {
return &MockMessageService_History_Call{Call: _e.mock.On("History", ctx, callerID, chatID, after, limit)}
}
func (_c *MockMessageService_History_Call) Run(run func(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID, after *domain.Cursor, limit int)) *MockMessageService_History_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 *domain.Cursor
if args[3] != nil {
arg3 = args[3].(*domain.Cursor)
}
var arg4 int
if args[4] != nil {
arg4 = args[4].(int)
}
run(
arg0,
arg1,
arg2,
arg3,
arg4,
)
})
return _c
}
func (_c *MockMessageService_History_Call) Return(page domain.Page[domain.Message], err error) *MockMessageService_History_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockMessageService_History_Call) RunAndReturn(run func(ctx context.Context, callerID uuid.UUID, chatID uuid.UUID, after *domain.Cursor, limit int) (domain.Page[domain.Message], error)) *MockMessageService_History_Call {
_c.Call.Return(run)
return _c
}
// Send provides a mock function for the type MockMessageService
func (_mock *MockMessageService) Send(ctx context.Context, draft domain.MessageDraft) (domain.Message, error) {
ret := _mock.Called(ctx, draft)
if len(ret) == 0 {
panic("no return value specified for Send")
}
var r0 domain.Message
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.MessageDraft) (domain.Message, error)); ok {
return returnFunc(ctx, draft)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.MessageDraft) domain.Message); ok {
r0 = returnFunc(ctx, draft)
} else {
r0 = ret.Get(0).(domain.Message)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.MessageDraft) error); ok {
r1 = returnFunc(ctx, draft)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockMessageService_Send_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Send'
type MockMessageService_Send_Call struct {
*mock.Call
}
// Send is a helper method to define mock.On call
// - ctx context.Context
// - draft domain.MessageDraft
func (_e *MockMessageService_Expecter) Send(ctx any, draft any) *MockMessageService_Send_Call {
return &MockMessageService_Send_Call{Call: _e.mock.On("Send", ctx, draft)}
}
func (_c *MockMessageService_Send_Call) Run(run func(ctx context.Context, draft domain.MessageDraft)) *MockMessageService_Send_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 domain.MessageDraft
if args[1] != nil {
arg1 = args[1].(domain.MessageDraft)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockMessageService_Send_Call) Return(message domain.Message, err error) *MockMessageService_Send_Call {
_c.Call.Return(message, err)
return _c
}
func (_c *MockMessageService_Send_Call) RunAndReturn(run func(ctx context.Context, draft domain.MessageDraft) (domain.Message, error)) *MockMessageService_Send_Call {
_c.Call.Return(run)
return _c
}
@@ -0,0 +1,186 @@
// 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"
)
// NewMockSecSessionService creates a new instance of MockSecSessionService. 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 NewMockSecSessionService(t interface {
mock.TestingT
Cleanup(func())
}) *MockSecSessionService {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockSecSessionService{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockSecSessionService is an autogenerated mock type for the SecSessionService type
type MockSecSessionService struct {
mock.Mock
}
type MockSecSessionService_Expecter struct {
mock *mock.Mock
}
func (_m *MockSecSessionService) EXPECT() *MockSecSessionService_Expecter {
return &MockSecSessionService_Expecter{mock: &_m.Mock}
}
// Authenticate provides a mock function for the type MockSecSessionService
func (_mock *MockSecSessionService) Authenticate(ctx context.Context, username string, password string) (domain.User, error) {
ret := _mock.Called(ctx, username, password)
if len(ret) == 0 {
panic("no return value specified for Authenticate")
}
var r0 domain.User
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (domain.User, error)); ok {
return returnFunc(ctx, username, password)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) domain.User); ok {
r0 = returnFunc(ctx, username, password)
} else {
r0 = ret.Get(0).(domain.User)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = returnFunc(ctx, username, password)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockSecSessionService_Authenticate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Authenticate'
type MockSecSessionService_Authenticate_Call struct {
*mock.Call
}
// Authenticate is a helper method to define mock.On call
// - ctx context.Context
// - username string
// - password string
func (_e *MockSecSessionService_Expecter) Authenticate(ctx any, username any, password any) *MockSecSessionService_Authenticate_Call {
return &MockSecSessionService_Authenticate_Call{Call: _e.mock.On("Authenticate", ctx, username, password)}
}
func (_c *MockSecSessionService_Authenticate_Call) Run(run func(ctx context.Context, username string, password string)) *MockSecSessionService_Authenticate_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)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockSecSessionService_Authenticate_Call) Return(user domain.User, err error) *MockSecSessionService_Authenticate_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockSecSessionService_Authenticate_Call) RunAndReturn(run func(ctx context.Context, username string, password string) (domain.User, error)) *MockSecSessionService_Authenticate_Call {
_c.Call.Return(run)
return _c
}
// Resolve provides a mock function for the type MockSecSessionService
func (_mock *MockSecSessionService) 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
}
// MockSecSessionService_Resolve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Resolve'
type MockSecSessionService_Resolve_Call struct {
*mock.Call
}
// Resolve is a helper method to define mock.On call
// - ctx context.Context
// - token string
func (_e *MockSecSessionService_Expecter) Resolve(ctx any, token any) *MockSecSessionService_Resolve_Call {
return &MockSecSessionService_Resolve_Call{Call: _e.mock.On("Resolve", ctx, token)}
}
func (_c *MockSecSessionService_Resolve_Call) Run(run func(ctx context.Context, token string)) *MockSecSessionService_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 *MockSecSessionService_Resolve_Call) Return(user domain.User, err error) *MockSecSessionService_Resolve_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockSecSessionService_Resolve_Call) RunAndReturn(run func(ctx context.Context, token string) (domain.User, error)) *MockSecSessionService_Resolve_Call {
_c.Call.Return(run)
return _c
}
@@ -0,0 +1,316 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockSessionActions creates a new instance of MockSessionActions. 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 NewMockSessionActions(t interface {
mock.TestingT
Cleanup(func())
}) *MockSessionActions {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockSessionActions{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockSessionActions is an autogenerated mock type for the SessionActions type
type MockSessionActions struct {
mock.Mock
}
type MockSessionActions_Expecter struct {
mock *mock.Mock
}
func (_m *MockSessionActions) EXPECT() *MockSessionActions_Expecter {
return &MockSessionActions_Expecter{mock: &_m.Mock}
}
// Authenticate provides a mock function for the type MockSessionActions
func (_mock *MockSessionActions) Authenticate(ctx context.Context, username string, password string) (domain.User, error) {
ret := _mock.Called(ctx, username, password)
if len(ret) == 0 {
panic("no return value specified for Authenticate")
}
var r0 domain.User
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (domain.User, error)); ok {
return returnFunc(ctx, username, password)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) domain.User); ok {
r0 = returnFunc(ctx, username, password)
} else {
r0 = ret.Get(0).(domain.User)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = returnFunc(ctx, username, password)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockSessionActions_Authenticate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Authenticate'
type MockSessionActions_Authenticate_Call struct {
*mock.Call
}
// Authenticate is a helper method to define mock.On call
// - ctx context.Context
// - username string
// - password string
func (_e *MockSessionActions_Expecter) Authenticate(ctx any, username any, password any) *MockSessionActions_Authenticate_Call {
return &MockSessionActions_Authenticate_Call{Call: _e.mock.On("Authenticate", ctx, username, password)}
}
func (_c *MockSessionActions_Authenticate_Call) Run(run func(ctx context.Context, username string, password string)) *MockSessionActions_Authenticate_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)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockSessionActions_Authenticate_Call) Return(user domain.User, err error) *MockSessionActions_Authenticate_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockSessionActions_Authenticate_Call) RunAndReturn(run func(ctx context.Context, username string, password string) (domain.User, error)) *MockSessionActions_Authenticate_Call {
_c.Call.Return(run)
return _c
}
// Create provides a mock function for the type MockSessionActions
func (_mock *MockSessionActions) Create(ctx context.Context, user domain.User) (domain.Session, error) {
ret := _mock.Called(ctx, user)
if len(ret) == 0 {
panic("no return value specified for Create")
}
var r0 domain.Session
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.User) (domain.Session, error)); ok {
return returnFunc(ctx, user)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.User) domain.Session); ok {
r0 = returnFunc(ctx, user)
} else {
r0 = ret.Get(0).(domain.Session)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.User) error); ok {
r1 = returnFunc(ctx, user)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockSessionActions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'
type MockSessionActions_Create_Call struct {
*mock.Call
}
// Create is a helper method to define mock.On call
// - ctx context.Context
// - user domain.User
func (_e *MockSessionActions_Expecter) Create(ctx any, user any) *MockSessionActions_Create_Call {
return &MockSessionActions_Create_Call{Call: _e.mock.On("Create", ctx, user)}
}
func (_c *MockSessionActions_Create_Call) Run(run func(ctx context.Context, user domain.User)) *MockSessionActions_Create_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 domain.User
if args[1] != nil {
arg1 = args[1].(domain.User)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockSessionActions_Create_Call) Return(session domain.Session, err error) *MockSessionActions_Create_Call {
_c.Call.Return(session, err)
return _c
}
func (_c *MockSessionActions_Create_Call) RunAndReturn(run func(ctx context.Context, user domain.User) (domain.Session, error)) *MockSessionActions_Create_Call {
_c.Call.Return(run)
return _c
}
// Resolve provides a mock function for the type MockSessionActions
func (_mock *MockSessionActions) 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
}
// MockSessionActions_Resolve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Resolve'
type MockSessionActions_Resolve_Call struct {
*mock.Call
}
// Resolve is a helper method to define mock.On call
// - ctx context.Context
// - token string
func (_e *MockSessionActions_Expecter) Resolve(ctx any, token any) *MockSessionActions_Resolve_Call {
return &MockSessionActions_Resolve_Call{Call: _e.mock.On("Resolve", ctx, token)}
}
func (_c *MockSessionActions_Resolve_Call) Run(run func(ctx context.Context, token string)) *MockSessionActions_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 *MockSessionActions_Resolve_Call) Return(user domain.User, err error) *MockSessionActions_Resolve_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockSessionActions_Resolve_Call) RunAndReturn(run func(ctx context.Context, token string) (domain.User, error)) *MockSessionActions_Resolve_Call {
_c.Call.Return(run)
return _c
}
// Revoke provides a mock function for the type MockSessionActions
func (_mock *MockSessionActions) Revoke(ctx context.Context, userID uuid.UUID, token string) error {
ret := _mock.Called(ctx, userID, token)
if len(ret) == 0 {
panic("no return value specified for Revoke")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) error); ok {
r0 = returnFunc(ctx, userID, token)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockSessionActions_Revoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Revoke'
type MockSessionActions_Revoke_Call struct {
*mock.Call
}
// Revoke is a helper method to define mock.On call
// - ctx context.Context
// - userID uuid.UUID
// - token string
func (_e *MockSessionActions_Expecter) Revoke(ctx any, userID any, token any) *MockSessionActions_Revoke_Call {
return &MockSessionActions_Revoke_Call{Call: _e.mock.On("Revoke", ctx, userID, token)}
}
func (_c *MockSessionActions_Revoke_Call) Run(run func(ctx context.Context, userID uuid.UUID, token string)) *MockSessionActions_Revoke_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 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockSessionActions_Revoke_Call) Return(err error) *MockSessionActions_Revoke_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockSessionActions_Revoke_Call) RunAndReturn(run func(ctx context.Context, userID uuid.UUID, token string) error) *MockSessionActions_Revoke_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
}
@@ -0,0 +1,178 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockSessionService creates a new instance of MockSessionService. 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 NewMockSessionService(t interface {
mock.TestingT
Cleanup(func())
}) *MockSessionService {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockSessionService{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockSessionService is an autogenerated mock type for the SessionService type
type MockSessionService struct {
mock.Mock
}
type MockSessionService_Expecter struct {
mock *mock.Mock
}
func (_m *MockSessionService) EXPECT() *MockSessionService_Expecter {
return &MockSessionService_Expecter{mock: &_m.Mock}
}
// Create provides a mock function for the type MockSessionService
func (_mock *MockSessionService) Create(ctx context.Context, user domain.User) (domain.Session, error) {
ret := _mock.Called(ctx, user)
if len(ret) == 0 {
panic("no return value specified for Create")
}
var r0 domain.Session
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.User) (domain.Session, error)); ok {
return returnFunc(ctx, user)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.User) domain.Session); ok {
r0 = returnFunc(ctx, user)
} else {
r0 = ret.Get(0).(domain.Session)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.User) error); ok {
r1 = returnFunc(ctx, user)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockSessionService_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'
type MockSessionService_Create_Call struct {
*mock.Call
}
// Create is a helper method to define mock.On call
// - ctx context.Context
// - user domain.User
func (_e *MockSessionService_Expecter) Create(ctx any, user any) *MockSessionService_Create_Call {
return &MockSessionService_Create_Call{Call: _e.mock.On("Create", ctx, user)}
}
func (_c *MockSessionService_Create_Call) Run(run func(ctx context.Context, user domain.User)) *MockSessionService_Create_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 domain.User
if args[1] != nil {
arg1 = args[1].(domain.User)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockSessionService_Create_Call) Return(session domain.Session, err error) *MockSessionService_Create_Call {
_c.Call.Return(session, err)
return _c
}
func (_c *MockSessionService_Create_Call) RunAndReturn(run func(ctx context.Context, user domain.User) (domain.Session, error)) *MockSessionService_Create_Call {
_c.Call.Return(run)
return _c
}
// Revoke provides a mock function for the type MockSessionService
func (_mock *MockSessionService) Revoke(ctx context.Context, userID uuid.UUID, token string) error {
ret := _mock.Called(ctx, userID, token)
if len(ret) == 0 {
panic("no return value specified for Revoke")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) error); ok {
r0 = returnFunc(ctx, userID, token)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockSessionService_Revoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Revoke'
type MockSessionService_Revoke_Call struct {
*mock.Call
}
// Revoke is a helper method to define mock.On call
// - ctx context.Context
// - userID uuid.UUID
// - token string
func (_e *MockSessionService_Expecter) Revoke(ctx any, userID any, token any) *MockSessionService_Revoke_Call {
return &MockSessionService_Revoke_Call{Call: _e.mock.On("Revoke", ctx, userID, token)}
}
func (_c *MockSessionService_Revoke_Call) Run(run func(ctx context.Context, userID uuid.UUID, token string)) *MockSessionService_Revoke_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 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockSessionService_Revoke_Call) Return(err error) *MockSessionService_Revoke_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockSessionService_Revoke_Call) RunAndReturn(run func(ctx context.Context, userID uuid.UUID, token string) error) *MockSessionService_Revoke_Call {
_c.Call.Return(run)
return _c
}
+115
View File
@@ -0,0 +1,115 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockUserLookup creates a new instance of MockUserLookup. 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 NewMockUserLookup(t interface {
mock.TestingT
Cleanup(func())
}) *MockUserLookup {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockUserLookup{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockUserLookup is an autogenerated mock type for the UserLookup type
type MockUserLookup struct {
mock.Mock
}
type MockUserLookup_Expecter struct {
mock *mock.Mock
}
func (_m *MockUserLookup) EXPECT() *MockUserLookup_Expecter {
return &MockUserLookup_Expecter{mock: &_m.Mock}
}
// GetByID provides a mock function for the type MockUserLookup
func (_mock *MockUserLookup) GetByID(ctx context.Context, id uuid.UUID) (domain.User, error) {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for GetByID")
}
var r0 domain.User
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID) (domain.User, error)); ok {
return returnFunc(ctx, id)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID) domain.User); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Get(0).(domain.User)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok {
r1 = returnFunc(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockUserLookup_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID'
type MockUserLookup_GetByID_Call struct {
*mock.Call
}
// GetByID is a helper method to define mock.On call
// - ctx context.Context
// - id uuid.UUID
func (_e *MockUserLookup_Expecter) GetByID(ctx any, id any) *MockUserLookup_GetByID_Call {
return &MockUserLookup_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)}
}
func (_c *MockUserLookup_GetByID_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUserLookup_GetByID_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)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockUserLookup_GetByID_Call) Return(user domain.User, err error) *MockUserLookup_GetByID_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockUserLookup_GetByID_Call) RunAndReturn(run func(ctx context.Context, id uuid.UUID) (domain.User, error)) *MockUserLookup_GetByID_Call {
_c.Call.Return(run)
return _c
}
@@ -0,0 +1,181 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"mtusi-messenger/internal/domain"
"github.com/google/uuid"
mock "github.com/stretchr/testify/mock"
)
// NewMockUserService creates a new instance of MockUserService. 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 NewMockUserService(t interface {
mock.TestingT
Cleanup(func())
}) *MockUserService {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock := &MockUserService{}
mock.Mock.Test(t)
t.Cleanup(func() {
if helper, ok := t.(interface{ Helper() }); ok {
helper.Helper()
}
mock.AssertExpectations(t)
})
return mock
}
// MockUserService is an autogenerated mock type for the UserService type
type MockUserService struct {
mock.Mock
}
type MockUserService_Expecter struct {
mock *mock.Mock
}
func (_m *MockUserService) EXPECT() *MockUserService_Expecter {
return &MockUserService_Expecter{mock: &_m.Mock}
}
// GetByID provides a mock function for the type MockUserService
func (_mock *MockUserService) GetByID(ctx context.Context, id uuid.UUID) (domain.User, error) {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for GetByID")
}
var r0 domain.User
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID) (domain.User, error)); ok {
return returnFunc(ctx, id)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, uuid.UUID) domain.User); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Get(0).(domain.User)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok {
r1 = returnFunc(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockUserService_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID'
type MockUserService_GetByID_Call struct {
*mock.Call
}
// GetByID is a helper method to define mock.On call
// - ctx context.Context
// - id uuid.UUID
func (_e *MockUserService_Expecter) GetByID(ctx any, id any) *MockUserService_GetByID_Call {
return &MockUserService_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)}
}
func (_c *MockUserService_GetByID_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUserService_GetByID_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)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockUserService_GetByID_Call) Return(user domain.User, err error) *MockUserService_GetByID_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockUserService_GetByID_Call) RunAndReturn(run func(ctx context.Context, id uuid.UUID) (domain.User, error)) *MockUserService_GetByID_Call {
_c.Call.Return(run)
return _c
}
// Register provides a mock function for the type MockUserService
func (_mock *MockUserService) Register(ctx context.Context, draft domain.UserDraft) (domain.User, error) {
ret := _mock.Called(ctx, draft)
if len(ret) == 0 {
panic("no return value specified for Register")
}
var r0 domain.User
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.UserDraft) (domain.User, error)); ok {
return returnFunc(ctx, draft)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, domain.UserDraft) domain.User); ok {
r0 = returnFunc(ctx, draft)
} else {
r0 = ret.Get(0).(domain.User)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, domain.UserDraft) error); ok {
r1 = returnFunc(ctx, draft)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockUserService_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register'
type MockUserService_Register_Call struct {
*mock.Call
}
// Register is a helper method to define mock.On call
// - ctx context.Context
// - draft domain.UserDraft
func (_e *MockUserService_Expecter) Register(ctx any, draft any) *MockUserService_Register_Call {
return &MockUserService_Register_Call{Call: _e.mock.On("Register", ctx, draft)}
}
func (_c *MockUserService_Register_Call) Run(run func(ctx context.Context, draft domain.UserDraft)) *MockUserService_Register_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 domain.UserDraft
if args[1] != nil {
arg1 = args[1].(domain.UserDraft)
}
run(
arg0,
arg1,
)
})
return _c
}
func (_c *MockUserService_Register_Call) Return(user domain.User, err error) *MockUserService_Register_Call {
_c.Call.Return(user, err)
return _c
}
func (_c *MockUserService_Register_Call) RunAndReturn(run func(ctx context.Context, draft domain.UserDraft) (domain.User, error)) *MockUserService_Register_Call {
_c.Call.Return(run)
return _c
}