Documentation ¶
Index ¶
- func IsDomainError(err error) bool
- type Repository
- type RepositoryMock
- func (mock *RepositoryMock) Create(ctx context.Context, account *entities.Account) error
- func (mock *RepositoryMock) CreateCalls() []struct{ ... }
- func (mock *RepositoryMock) GetAccounts(ctx context.Context) ([]entities.Account, error)
- func (mock *RepositoryMock) GetAccountsCalls() []struct{ ... }
- func (mock *RepositoryMock) GetByCPF(ctx context.Context, CPF string) (*entities.Account, error)
- func (mock *RepositoryMock) GetByCPFCalls() []struct{ ... }
- func (mock *RepositoryMock) GetByID(ctx context.Context, accountID string) (*entities.Account, error)
- func (mock *RepositoryMock) GetByIDCalls() []struct{ ... }
- func (mock *RepositoryMock) UpdateBalance(ctx context.Context, ID string) error
- func (mock *RepositoryMock) UpdateBalanceCalls() []struct{ ... }
- type UseCase
- type UseCaseMock
- func (mock *UseCaseMock) Create(ctx context.Context, input entities.CreateAccountInput) (*entities.Account, error)
- func (mock *UseCaseMock) CreateCalls() []struct{ ... }
- func (mock *UseCaseMock) GetByCPF(ctx context.Context, CPF string) (*entities.Account, error)
- func (mock *UseCaseMock) GetByCPFCalls() []struct{ ... }
- func (mock *UseCaseMock) GetByID(ctx context.Context, accountID string) (*entities.Account, error)
- func (mock *UseCaseMock) GetByIDCalls() []struct{ ... }
- func (mock *UseCaseMock) List(ctx context.Context) ([]entities.Account, error)
- func (mock *UseCaseMock) ListCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDomainError ¶
Check if some error belongs to the account domain
Types ¶
type Repository ¶
type Repository interface { Create(ctx context.Context, account *entities.Account) error GetByID(ctx context.Context, accountID string) (*entities.Account, error) GetByCPF(ctx context.Context, CPF string) (*entities.Account, error) GetAccounts(ctx context.Context) ([]entities.Account, error) UpdateBalance(ctx context.Context, ID string) error }
type RepositoryMock ¶
type RepositoryMock struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, account *entities.Account) error // GetAccountsFunc mocks the GetAccounts method. GetAccountsFunc func(ctx context.Context) ([]entities.Account, error) // GetByCPFFunc mocks the GetByCPF method. GetByCPFFunc func(ctx context.Context, CPF string) (*entities.Account, error) // GetByIDFunc mocks the GetByID method. GetByIDFunc func(ctx context.Context, accountID string) (*entities.Account, error) // UpdateBalanceFunc mocks the UpdateBalance method. UpdateBalanceFunc func(ctx context.Context, ID string) error // contains filtered or unexported fields }
RepositoryMock is a mock implementation of Repository.
func TestSomethingThatUsesRepository(t *testing.T) { // make and configure a mocked Repository mockedRepository := &RepositoryMock{ CreateFunc: func(ctx context.Context, account *entities.Account) error { panic("mock out the Create method") }, GetAccountsFunc: func(ctx context.Context) ([]entities.Account, error) { panic("mock out the GetAccounts method") }, GetByCPFFunc: func(ctx context.Context, CPF string) (*entities.Account, error) { panic("mock out the GetByCPF method") }, GetByIDFunc: func(ctx context.Context, accountID string) (*entities.Account, error) { panic("mock out the GetByID method") }, UpdateBalanceFunc: func(ctx context.Context, ID string) error { panic("mock out the UpdateBalance method") }, } // use mockedRepository in code that requires Repository // and then make assertions. }
func (*RepositoryMock) CreateCalls ¶
func (mock *RepositoryMock) CreateCalls() []struct { Ctx context.Context Account *entities.Account }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedRepository.CreateCalls())
func (*RepositoryMock) GetAccounts ¶
GetAccounts calls GetAccountsFunc.
func (*RepositoryMock) GetAccountsCalls ¶
func (mock *RepositoryMock) GetAccountsCalls() []struct { Ctx context.Context }
GetAccountsCalls gets all the calls that were made to GetAccounts. Check the length with:
len(mockedRepository.GetAccountsCalls())
func (*RepositoryMock) GetByCPFCalls ¶
func (mock *RepositoryMock) GetByCPFCalls() []struct { Ctx context.Context CPF string }
GetByCPFCalls gets all the calls that were made to GetByCPF. Check the length with:
len(mockedRepository.GetByCPFCalls())
func (*RepositoryMock) GetByID ¶
func (mock *RepositoryMock) GetByID(ctx context.Context, accountID string) (*entities.Account, error)
GetByID calls GetByIDFunc.
func (*RepositoryMock) GetByIDCalls ¶
func (mock *RepositoryMock) GetByIDCalls() []struct { Ctx context.Context AccountID string }
GetByIDCalls gets all the calls that were made to GetByID. Check the length with:
len(mockedRepository.GetByIDCalls())
func (*RepositoryMock) UpdateBalance ¶
func (mock *RepositoryMock) UpdateBalance(ctx context.Context, ID string) error
UpdateBalance calls UpdateBalanceFunc.
func (*RepositoryMock) UpdateBalanceCalls ¶
func (mock *RepositoryMock) UpdateBalanceCalls() []struct { Ctx context.Context ID string }
UpdateBalanceCalls gets all the calls that were made to UpdateBalance. Check the length with:
len(mockedRepository.UpdateBalanceCalls())
type UseCase ¶
type UseCase interface { List(ctx context.Context) ([]entities.Account, error) Create(ctx context.Context, input entities.CreateAccountInput) (*entities.Account, error) GetByID(ctx context.Context, accountID string) (*entities.Account, error) GetByCPF(ctx context.Context, CPF string) (*entities.Account, error) }
type UseCaseMock ¶
type UseCaseMock struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, input entities.CreateAccountInput) (*entities.Account, error) // GetByCPFFunc mocks the GetByCPF method. GetByCPFFunc func(ctx context.Context, CPF string) (*entities.Account, error) // GetByIDFunc mocks the GetByID method. GetByIDFunc func(ctx context.Context, accountID string) (*entities.Account, error) // ListFunc mocks the List method. ListFunc func(ctx context.Context) ([]entities.Account, error) // contains filtered or unexported fields }
UseCaseMock is a mock implementation of UseCase.
func TestSomethingThatUsesUseCase(t *testing.T) { // make and configure a mocked UseCase mockedUseCase := &UseCaseMock{ CreateFunc: func(ctx context.Context, input entities.CreateAccountInput) (*entities.Account, error) { panic("mock out the Create method") }, GetByCPFFunc: func(ctx context.Context, CPF string) (*entities.Account, error) { panic("mock out the GetByCPF method") }, GetByIDFunc: func(ctx context.Context, accountID string) (*entities.Account, error) { panic("mock out the GetByID method") }, ListFunc: func(ctx context.Context) ([]entities.Account, error) { panic("mock out the List method") }, } // use mockedUseCase in code that requires UseCase // and then make assertions. }
func (*UseCaseMock) Create ¶
func (mock *UseCaseMock) Create(ctx context.Context, input entities.CreateAccountInput) (*entities.Account, error)
Create calls CreateFunc.
func (*UseCaseMock) CreateCalls ¶
func (mock *UseCaseMock) CreateCalls() []struct { Ctx context.Context Input entities.CreateAccountInput }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedUseCase.CreateCalls())
func (*UseCaseMock) GetByCPFCalls ¶
func (mock *UseCaseMock) GetByCPFCalls() []struct { Ctx context.Context CPF string }
GetByCPFCalls gets all the calls that were made to GetByCPF. Check the length with:
len(mockedUseCase.GetByCPFCalls())
func (*UseCaseMock) GetByIDCalls ¶
func (mock *UseCaseMock) GetByIDCalls() []struct { Ctx context.Context AccountID string }
GetByIDCalls gets all the calls that were made to GetByID. Check the length with:
len(mockedUseCase.GetByIDCalls())
func (*UseCaseMock) ListCalls ¶
func (mock *UseCaseMock) ListCalls() []struct { Ctx context.Context }
ListCalls gets all the calls that were made to List. Check the length with:
len(mockedUseCase.ListCalls())