Documentation
¶
Index ¶
- func AssertStatus(t *testing.T, handler http.Handler, method string, path string, body any, ...) (http.ResponseWriter, *http.Request)
- func NewMockBitcoinRepository() bitcoinEntity.BTCRepository
- func NewMockUserRepository() userEntity.UserRepository
- type MockBTCRepository
- type MockUserRepository
- func (mock *MockUserRepository) Create(user *entity.User) error
- func (mock *MockUserRepository) CreateCalls() []struct{ ... }
- func (mock *MockUserRepository) Delete(id uint64) error
- func (mock *MockUserRepository) DeleteCalls() []struct{ ... }
- func (mock *MockUserRepository) Get(id uint64) (*entity.User, error)
- func (mock *MockUserRepository) GetCalls() []struct{ ... }
- func (mock *MockUserRepository) Update(id uint64, updFunc func(*entity.User) (*entity.User, error)) error
- func (mock *MockUserRepository) UpdateCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStatus ¶
func NewMockBitcoinRepository ¶
func NewMockBitcoinRepository() bitcoinEntity.BTCRepository
func NewMockUserRepository ¶
func NewMockUserRepository() userEntity.UserRepository
Types ¶
type MockBTCRepository ¶
type MockBTCRepository struct {
// GetFunc mocks the Get method.
GetFunc func() entity.BTCPrice
// SetPriceFunc mocks the SetPrice method.
SetPriceFunc func(price entity.USD) error
// contains filtered or unexported fields
}
MockBTCRepository is a mock implementation of entity.BTCRepository.
func TestSomethingThatUsesBTCRepository(t *testing.T) {
// make and configure a mocked entity.BTCRepository
mockedBTCRepository := &MockBTCRepository{
GetFunc: func() entity.BTCPrice {
panic("mock out the Get method")
},
SetPriceFunc: func(price entity.USD) error {
panic("mock out the SetPrice method")
},
}
// use mockedBTCRepository in code that requires entity.BTCRepository
// and then make assertions.
}
func (*MockBTCRepository) Get ¶
func (mock *MockBTCRepository) Get() entity.BTCPrice
Get calls GetFunc.
func (*MockBTCRepository) GetCalls ¶
func (mock *MockBTCRepository) GetCalls() []struct { }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedBTCRepository.GetCalls())
func (*MockBTCRepository) SetPrice ¶
func (mock *MockBTCRepository) SetPrice(price entity.USD) error
SetPrice calls SetPriceFunc.
func (*MockBTCRepository) SetPriceCalls ¶
func (mock *MockBTCRepository) SetPriceCalls() []struct { Price entity.USD }
SetPriceCalls gets all the calls that were made to SetPrice. Check the length with:
len(mockedBTCRepository.SetPriceCalls())
type MockUserRepository ¶
type MockUserRepository struct {
// CreateFunc mocks the Create method.
CreateFunc func(user *entity.User) error
// DeleteFunc mocks the Delete method.
DeleteFunc func(id uint64) error
// GetFunc mocks the Get method.
GetFunc func(id uint64) (*entity.User, error)
// UpdateFunc mocks the Update method.
UpdateFunc func(id uint64, updFunc func(*entity.User) (*entity.User, error)) error
// contains filtered or unexported fields
}
MockUserRepository is a mock implementation of entity.UserRepository.
func TestSomethingThatUsesUserRepository(t *testing.T) {
// make and configure a mocked entity.UserRepository
mockedUserRepository := &MockUserRepository{
CreateFunc: func(user *entity.User) error {
panic("mock out the Create method")
},
DeleteFunc: func(id uint64) error {
panic("mock out the Delete method")
},
GetFunc: func(id uint64) (*entity.User, error) {
panic("mock out the Get method")
},
UpdateFunc: func(id uint64, updFunc func(*entity.User) (*entity.User, error)) error {
panic("mock out the Update method")
},
}
// use mockedUserRepository in code that requires entity.UserRepository
// and then make assertions.
}
func (*MockUserRepository) Create ¶
func (mock *MockUserRepository) Create(user *entity.User) error
Create calls CreateFunc.
func (*MockUserRepository) CreateCalls ¶
func (mock *MockUserRepository) CreateCalls() []struct { User *entity.User }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedUserRepository.CreateCalls())
func (*MockUserRepository) Delete ¶
func (mock *MockUserRepository) Delete(id uint64) error
Delete calls DeleteFunc.
func (*MockUserRepository) DeleteCalls ¶
func (mock *MockUserRepository) DeleteCalls() []struct { ID uint64 }
DeleteCalls gets all the calls that were made to Delete. Check the length with:
len(mockedUserRepository.DeleteCalls())
func (*MockUserRepository) Get ¶
func (mock *MockUserRepository) Get(id uint64) (*entity.User, error)
Get calls GetFunc.
func (*MockUserRepository) GetCalls ¶
func (mock *MockUserRepository) GetCalls() []struct { ID uint64 }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedUserRepository.GetCalls())
func (*MockUserRepository) Update ¶
func (mock *MockUserRepository) Update(id uint64, updFunc func(*entity.User) (*entity.User, error)) error
Update calls UpdateFunc.
func (*MockUserRepository) UpdateCalls ¶
func (mock *MockUserRepository) UpdateCalls() []struct { ID uint64 UpdFunc func(*entity.User) (*entity.User, error) }
UpdateCalls gets all the calls that were made to Update. Check the length with:
len(mockedUserRepository.UpdateCalls())