Documentation
¶
Index ¶
- type DBMock
- func (mock *DBMock) Create(value interface{}) *gorm.DB
- func (mock *DBMock) CreateCalls() []struct{ ... }
- func (mock *DBMock) Delete(value interface{}, conds ...interface{}) *gorm.DB
- func (mock *DBMock) DeleteCalls() []struct{ ... }
- func (mock *DBMock) Find(dest interface{}, conds ...interface{}) *gorm.DB
- func (mock *DBMock) FindCalls() []struct{ ... }
- func (mock *DBMock) First(dest interface{}, conds ...interface{}) *gorm.DB
- func (mock *DBMock) FirstCalls() []struct{ ... }
- func (mock *DBMock) Save(value interface{}) *gorm.DB
- func (mock *DBMock) SaveCalls() []struct{ ... }
- type UserRepositoryMock
- func (mock *UserRepositoryMock) CreateUser(user *model.User) error
- func (mock *UserRepositoryMock) CreateUserCalls() []struct{ ... }
- func (mock *UserRepositoryMock) DeleteUser(id uuid.UUID) error
- func (mock *UserRepositoryMock) DeleteUserCalls() []struct{ ... }
- func (mock *UserRepositoryMock) GetUserByID(id uuid.UUID) (*model.User, error)
- func (mock *UserRepositoryMock) GetUserByIDCalls() []struct{ ... }
- func (mock *UserRepositoryMock) ListUsers() ([]*model.User, error)
- func (mock *UserRepositoryMock) ListUsersCalls() []struct{}
- func (mock *UserRepositoryMock) UpdateUser(user *model.User) error
- func (mock *UserRepositoryMock) UpdateUserCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBMock ¶
type DBMock struct { // CreateFunc mocks the Create method. CreateFunc func(value interface{}) *gorm.DB // DeleteFunc mocks the Delete method. DeleteFunc func(value interface{}, conds ...interface{}) *gorm.DB // FindFunc mocks the Find method. FindFunc func(dest interface{}, conds ...interface{}) *gorm.DB // FirstFunc mocks the First method. FirstFunc func(dest interface{}, conds ...interface{}) *gorm.DB // SaveFunc mocks the Save method. SaveFunc func(value interface{}) *gorm.DB // contains filtered or unexported fields }
DBMock is a mock implementation of repository.DB.
func TestSomethingThatUsesDB(t *testing.T) { // make and configure a mocked repository.DB mockedDB := &DBMock{ CreateFunc: func(value interface{}) *gorm.DB { panic("mock out the Create method") }, DeleteFunc: func(value interface{}, conds ...interface{}) *gorm.DB { panic("mock out the Delete method") }, FindFunc: func(dest interface{}, conds ...interface{}) *gorm.DB { panic("mock out the Find method") }, FirstFunc: func(dest interface{}, conds ...interface{}) *gorm.DB { panic("mock out the First method") }, SaveFunc: func(value interface{}) *gorm.DB { panic("mock out the Save method") }, } // use mockedDB in code that requires repository.DB // and then make assertions. }
func (*DBMock) CreateCalls ¶
func (mock *DBMock) CreateCalls() []struct { Value interface{} }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedDB.CreateCalls())
func (*DBMock) DeleteCalls ¶
func (mock *DBMock) DeleteCalls() []struct { Value interface{} Conds []interface{} }
DeleteCalls gets all the calls that were made to Delete. Check the length with:
len(mockedDB.DeleteCalls())
func (*DBMock) FindCalls ¶
func (mock *DBMock) FindCalls() []struct { Dest interface{} Conds []interface{} }
FindCalls gets all the calls that were made to Find. Check the length with:
len(mockedDB.FindCalls())
func (*DBMock) FirstCalls ¶
func (mock *DBMock) FirstCalls() []struct { Dest interface{} Conds []interface{} }
FirstCalls gets all the calls that were made to First. Check the length with:
len(mockedDB.FirstCalls())
type UserRepositoryMock ¶
type UserRepositoryMock struct { // CreateUserFunc mocks the CreateUser method. CreateUserFunc func(user *model.User) error // DeleteUserFunc mocks the DeleteUser method. DeleteUserFunc func(id uuid.UUID) error // GetUserByIDFunc mocks the GetUserByID method. GetUserByIDFunc func(id uuid.UUID) (*model.User, error) // ListUsersFunc mocks the ListUsers method. ListUsersFunc func() ([]*model.User, error) // UpdateUserFunc mocks the UpdateUser method. UpdateUserFunc func(user *model.User) error // contains filtered or unexported fields }
UserRepositoryMock is a mock implementation of repository.UserRepository.
func TestSomethingThatUsesUserRepository(t *testing.T) { // make and configure a mocked repository.UserRepository mockedUserRepository := &UserRepositoryMock{ CreateUserFunc: func(user *model.User) error { panic("mock out the CreateUser method") }, DeleteUserFunc: func(id uuid.UUID) error { panic("mock out the DeleteUser method") }, GetUserByIDFunc: func(id uuid.UUID) (*model.User, error) { panic("mock out the GetUserByID method") }, ListUsersFunc: func() ([]*model.User, error) { panic("mock out the ListUsers method") }, UpdateUserFunc: func(user *model.User) error { panic("mock out the UpdateUser method") }, } // use mockedUserRepository in code that requires repository.UserRepository // and then make assertions. }
func (*UserRepositoryMock) CreateUser ¶
func (mock *UserRepositoryMock) CreateUser(user *model.User) error
CreateUser calls CreateUserFunc.
func (*UserRepositoryMock) CreateUserCalls ¶
func (mock *UserRepositoryMock) CreateUserCalls() []struct { User *model.User }
CreateUserCalls gets all the calls that were made to CreateUser. Check the length with:
len(mockedUserRepository.CreateUserCalls())
func (*UserRepositoryMock) DeleteUser ¶
func (mock *UserRepositoryMock) DeleteUser(id uuid.UUID) error
DeleteUser calls DeleteUserFunc.
func (*UserRepositoryMock) DeleteUserCalls ¶
func (mock *UserRepositoryMock) DeleteUserCalls() []struct { ID uuid.UUID }
DeleteUserCalls gets all the calls that were made to DeleteUser. Check the length with:
len(mockedUserRepository.DeleteUserCalls())
func (*UserRepositoryMock) GetUserByID ¶
func (mock *UserRepositoryMock) GetUserByID(id uuid.UUID) (*model.User, error)
GetUserByID calls GetUserByIDFunc.
func (*UserRepositoryMock) GetUserByIDCalls ¶
func (mock *UserRepositoryMock) GetUserByIDCalls() []struct { ID uuid.UUID }
GetUserByIDCalls gets all the calls that were made to GetUserByID. Check the length with:
len(mockedUserRepository.GetUserByIDCalls())
func (*UserRepositoryMock) ListUsers ¶
func (mock *UserRepositoryMock) ListUsers() ([]*model.User, error)
ListUsers calls ListUsersFunc.
func (*UserRepositoryMock) ListUsersCalls ¶
func (mock *UserRepositoryMock) ListUsersCalls() []struct { }
ListUsersCalls gets all the calls that were made to ListUsers. Check the length with:
len(mockedUserRepository.ListUsersCalls())
func (*UserRepositoryMock) UpdateUser ¶
func (mock *UserRepositoryMock) UpdateUser(user *model.User) error
UpdateUser calls UpdateUserFunc.
func (*UserRepositoryMock) UpdateUserCalls ¶
func (mock *UserRepositoryMock) UpdateUserCalls() []struct { User *model.User }
UpdateUserCalls gets all the calls that were made to UpdateUser. Check the length with:
len(mockedUserRepository.UpdateUserCalls())