Documentation ¶
Index ¶
- type CreateAccountInput
- type Repository
- type RepositoryMock
- func (mock *RepositoryMock) CreateAccount(ctx context.Context, account entities.Account) error
- func (mock *RepositoryMock) CreateAccountCalls() []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, id string) (entities.Account, error)
- func (mock *RepositoryMock) GetByIdCalls() []struct{ ... }
- func (mock *RepositoryMock) UpdateBalance(ctx context.Context, id string, value int) error
- func (mock *RepositoryMock) UpdateBalanceCalls() []struct{ ... }
- type UseCase
- type UseCaseMock
- func (mock *UseCaseMock) Create(ctx context.Context, input CreateAccountInput) (entities.Account, error)
- func (mock *UseCaseMock) CreateCalls() []struct{ ... }
- func (mock *UseCaseMock) GetAccounts(ctx context.Context) ([]entities.Account, error)
- func (mock *UseCaseMock) GetAccountsCalls() []struct{ ... }
- func (mock *UseCaseMock) GetBalance(ctx context.Context, id string) (int, error)
- func (mock *UseCaseMock) GetBalanceCalls() []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, id string) (entities.Account, error)
- func (mock *UseCaseMock) GetByIdCalls() []struct{ ... }
- func (mock *UseCaseMock) UpdateBalance(ctx context.Context, originAccountId string, destinationAccountId string, ...) error
- func (mock *UseCaseMock) UpdateBalanceCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateAccountInput ¶
type Repository ¶
type Repository interface { CreateAccount(ctx context.Context, account entities.Account) error GetById(ctx context.Context, id 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, value int) error }
type RepositoryMock ¶
type RepositoryMock struct { // CreateAccountFunc mocks the CreateAccount method. CreateAccountFunc 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, id string) (entities.Account, error) // UpdateBalanceFunc mocks the UpdateBalance method. UpdateBalanceFunc func(ctx context.Context, id string, value int) 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{ CreateAccountFunc: func(ctx context.Context, account entities.Account) error { panic("mock out the CreateAccount 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, id string) (entities.Account, error) { panic("mock out the GetById method") }, UpdateBalanceFunc: func(ctx context.Context, id string, value int) error { panic("mock out the UpdateBalance method") }, } // use mockedRepository in code that requires Repository // and then make assertions. }
func (*RepositoryMock) CreateAccount ¶
CreateAccount calls CreateAccountFunc.
func (*RepositoryMock) CreateAccountCalls ¶
func (mock *RepositoryMock) CreateAccountCalls() []struct { Ctx context.Context Account entities.Account }
CreateAccountCalls gets all the calls that were made to CreateAccount. Check the length with:
len(mockedRepository.CreateAccountCalls())
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) GetByIdCalls ¶
func (mock *RepositoryMock) GetByIdCalls() []struct { Ctx context.Context ID string }
GetByIdCalls gets all the calls that were made to GetById. Check the length with:
len(mockedRepository.GetByIdCalls())
func (*RepositoryMock) UpdateBalance ¶
UpdateBalance calls UpdateBalanceFunc.
func (*RepositoryMock) UpdateBalanceCalls ¶
func (mock *RepositoryMock) UpdateBalanceCalls() []struct { Ctx context.Context ID string Value int }
UpdateBalanceCalls gets all the calls that were made to UpdateBalance. Check the length with:
len(mockedRepository.UpdateBalanceCalls())
type UseCase ¶
type UseCase interface { Create(ctx context.Context, input CreateAccountInput) (entities.Account, error) GetAccounts(ctx context.Context) ([]entities.Account, error) GetBalance(ctx context.Context, id string) (int, error) GetById(ctx context.Context, id string) (entities.Account, error) GetByCpf(ctx context.Context, cpf string) (entities.Account, error) UpdateBalance(ctx context.Context, originAccountId, destinationAccountId string, amount int) error }
type UseCaseMock ¶
type UseCaseMock struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, input CreateAccountInput) (entities.Account, error) // GetAccountsFunc mocks the GetAccounts method. GetAccountsFunc func(ctx context.Context) ([]entities.Account, error) // GetBalanceFunc mocks the GetBalance method. GetBalanceFunc func(ctx context.Context, id string) (int, 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, id string) (entities.Account, error) // UpdateBalanceFunc mocks the UpdateBalance method. UpdateBalanceFunc func(ctx context.Context, originAccountId string, destinationAccountId string, amount int) 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 CreateAccountInput) (entities.Account, error) { panic("mock out the Create method") }, GetAccountsFunc: func(ctx context.Context) ([]entities.Account, error) { panic("mock out the GetAccounts method") }, GetBalanceFunc: func(ctx context.Context, id string) (int, error) { panic("mock out the GetBalance method") }, GetByCpfFunc: func(ctx context.Context, cpf string) (entities.Account, error) { panic("mock out the GetByCpf method") }, GetByIdFunc: func(ctx context.Context, id string) (entities.Account, error) { panic("mock out the GetById method") }, UpdateBalanceFunc: func(ctx context.Context, originAccountId string, destinationAccountId string, amount int) error { panic("mock out the UpdateBalance method") }, } // use mockedUseCase in code that requires UseCase // and then make assertions. }
func (*UseCaseMock) Create ¶
func (mock *UseCaseMock) Create(ctx context.Context, input CreateAccountInput) (entities.Account, error)
Create calls CreateFunc.
func (*UseCaseMock) CreateCalls ¶
func (mock *UseCaseMock) CreateCalls() []struct { Ctx context.Context Input CreateAccountInput }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedUseCase.CreateCalls())
func (*UseCaseMock) GetAccounts ¶
GetAccounts calls GetAccountsFunc.
func (*UseCaseMock) GetAccountsCalls ¶
func (mock *UseCaseMock) GetAccountsCalls() []struct { Ctx context.Context }
GetAccountsCalls gets all the calls that were made to GetAccounts. Check the length with:
len(mockedUseCase.GetAccountsCalls())
func (*UseCaseMock) GetBalance ¶
GetBalance calls GetBalanceFunc.
func (*UseCaseMock) GetBalanceCalls ¶
func (mock *UseCaseMock) GetBalanceCalls() []struct { Ctx context.Context ID string }
GetBalanceCalls gets all the calls that were made to GetBalance. Check the length with:
len(mockedUseCase.GetBalanceCalls())
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 ID string }
GetByIdCalls gets all the calls that were made to GetById. Check the length with:
len(mockedUseCase.GetByIdCalls())
func (*UseCaseMock) UpdateBalance ¶
func (mock *UseCaseMock) UpdateBalance(ctx context.Context, originAccountId string, destinationAccountId string, amount int) error
UpdateBalance calls UpdateBalanceFunc.
func (*UseCaseMock) UpdateBalanceCalls ¶
func (mock *UseCaseMock) UpdateBalanceCalls() []struct { Ctx context.Context OriginAccountId string DestinationAccountId string Amount int }
UpdateBalanceCalls gets all the calls that were made to UpdateBalance. Check the length with:
len(mockedUseCase.UpdateBalanceCalls())