transfer

package
v0.0.0-...-5927a11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateTransferInput

type CreateTransferInput struct {
	OriginAccount      entities.Account
	DestinationAccount entities.Account
	Amount             int
}

type Repository

type Repository interface {
	CreateTransfer(ctx context.Context, transfer entities.Transfer, accountID string) error
	GetTransfersByAccountID(ctx context.Context, accountID string) ([]entities.Transfer, error)
}

type RepositoryMock

type RepositoryMock struct {
	// CreateTransferFunc mocks the CreateTransfer method.
	CreateTransferFunc func(ctx context.Context, transfer entities.Transfer, accountID string) error

	// GetTransfersByAccountIDFunc mocks the GetTransfersByAccountID method.
	GetTransfersByAccountIDFunc func(ctx context.Context, accountID string) ([]entities.Transfer, 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{
		CreateTransferFunc: func(ctx context.Context, transfer entities.Transfer, accountID string) error {
			panic("mock out the CreateTransfer method")
		},
		GetTransfersByAccountIDFunc: func(ctx context.Context, accountID string) ([]entities.Transfer, error) {
			panic("mock out the GetTransfersByAccountID method")
		},
	}

	// use mockedRepository in code that requires Repository
	// and then make assertions.

}

func (*RepositoryMock) CreateTransfer

func (mock *RepositoryMock) CreateTransfer(ctx context.Context, transfer entities.Transfer, accountID string) error

CreateTransfer calls CreateTransferFunc.

func (*RepositoryMock) CreateTransferCalls

func (mock *RepositoryMock) CreateTransferCalls() []struct {
	Ctx       context.Context
	Transfer  entities.Transfer
	AccountID string
}

CreateTransferCalls gets all the calls that were made to CreateTransfer. Check the length with:

len(mockedRepository.CreateTransferCalls())

func (*RepositoryMock) GetTransfersByAccountID

func (mock *RepositoryMock) GetTransfersByAccountID(ctx context.Context, accountID string) ([]entities.Transfer, error)

GetTransfersByAccountID calls GetTransfersByAccountIDFunc.

func (*RepositoryMock) GetTransfersByAccountIDCalls

func (mock *RepositoryMock) GetTransfersByAccountIDCalls() []struct {
	Ctx       context.Context
	AccountID string
}

GetTransfersByAccountIDCalls gets all the calls that were made to GetTransfersByAccountID. Check the length with:

len(mockedRepository.GetTransfersByAccountIDCalls())

type UseCase

type UseCase interface {
	Create(ctx context.Context, input CreateTransferInput) (entities.Transfer, error)
	GetTransfersByAccountID(ctx context.Context, accountID string) ([]entities.Transfer, error)
}

type UseCaseMock

type UseCaseMock struct {
	// CreateFunc mocks the Create method.
	CreateFunc func(ctx context.Context, input CreateTransferInput) (entities.Transfer, error)

	// GetTransfersByAccountIDFunc mocks the GetTransfersByAccountID method.
	GetTransfersByAccountIDFunc func(ctx context.Context, accountID string) ([]entities.Transfer, 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 CreateTransferInput) (entities.Transfer, error) {
			panic("mock out the Create method")
		},
		GetTransfersByAccountIDFunc: func(ctx context.Context, accountID string) ([]entities.Transfer, error) {
			panic("mock out the GetTransfersByAccountID method")
		},
	}

	// use mockedUseCase in code that requires UseCase
	// and then make assertions.

}

func (*UseCaseMock) Create

Create calls CreateFunc.

func (*UseCaseMock) CreateCalls

func (mock *UseCaseMock) CreateCalls() []struct {
	Ctx   context.Context
	Input CreateTransferInput
}

CreateCalls gets all the calls that were made to Create. Check the length with:

len(mockedUseCase.CreateCalls())

func (*UseCaseMock) GetTransfersByAccountID

func (mock *UseCaseMock) GetTransfersByAccountID(ctx context.Context, accountID string) ([]entities.Transfer, error)

GetTransfersByAccountID calls GetTransfersByAccountIDFunc.

func (*UseCaseMock) GetTransfersByAccountIDCalls

func (mock *UseCaseMock) GetTransfersByAccountIDCalls() []struct {
	Ctx       context.Context
	AccountID string
}

GetTransfersByAccountIDCalls gets all the calls that were made to GetTransfersByAccountID. Check the length with:

len(mockedUseCase.GetTransfersByAccountIDCalls())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL