authentication

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 LoginInputs

type LoginInputs struct {
	CPF     string
	Secret  string
	Account entities.Account
}

type Repository

type Repository interface {
	CreateToken(ctx context.Context, token entities.Token) error
	GetToken(ctx context.Context, id string) (entities.Token, error)
}

type RepositoryMock

type RepositoryMock struct {
	// CreateTokenFunc mocks the CreateToken method.
	CreateTokenFunc func(ctx context.Context, token entities.Token) error

	// GetTokenFunc mocks the GetToken method.
	GetTokenFunc func(ctx context.Context, id string) (entities.Token, 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{
		CreateTokenFunc: func(ctx context.Context, token entities.Token) error {
			panic("mock out the CreateToken method")
		},
		GetTokenFunc: func(ctx context.Context, id string) (entities.Token, error) {
			panic("mock out the GetToken method")
		},
	}

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

}

func (*RepositoryMock) CreateToken

func (mock *RepositoryMock) CreateToken(ctx context.Context, token entities.Token) error

CreateToken calls CreateTokenFunc.

func (*RepositoryMock) CreateTokenCalls

func (mock *RepositoryMock) CreateTokenCalls() []struct {
	Ctx   context.Context
	Token entities.Token
}

CreateTokenCalls gets all the calls that were made to CreateToken. Check the length with:

len(mockedRepository.CreateTokenCalls())

func (*RepositoryMock) GetToken

func (mock *RepositoryMock) GetToken(ctx context.Context, id string) (entities.Token, error)

GetToken calls GetTokenFunc.

func (*RepositoryMock) GetTokenCalls

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

GetTokenCalls gets all the calls that were made to GetToken. Check the length with:

len(mockedRepository.GetTokenCalls())

type UseCase

type UseCase interface {
	CreateToken(ctx context.Context, login LoginInputs) (string, error)
	ValidatesToken(ctx context.Context, tokenString string) (entities.Token, error)
}

type UseCaseMock

type UseCaseMock struct {
	// CreateTokenFunc mocks the CreateToken method.
	CreateTokenFunc func(ctx context.Context, login LoginInputs) (string, error)

	// ValidatesTokenFunc mocks the ValidatesToken method.
	ValidatesTokenFunc func(ctx context.Context, tokenString string) (entities.Token, 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{
		CreateTokenFunc: func(ctx context.Context, login LoginInputs) (string, error) {
			panic("mock out the CreateToken method")
		},
		ValidatesTokenFunc: func(ctx context.Context, tokenString string) (entities.Token, error) {
			panic("mock out the ValidatesToken method")
		},
	}

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

}

func (*UseCaseMock) CreateToken

func (mock *UseCaseMock) CreateToken(ctx context.Context, login LoginInputs) (string, error)

CreateToken calls CreateTokenFunc.

func (*UseCaseMock) CreateTokenCalls

func (mock *UseCaseMock) CreateTokenCalls() []struct {
	Ctx   context.Context
	Login LoginInputs
}

CreateTokenCalls gets all the calls that were made to CreateToken. Check the length with:

len(mockedUseCase.CreateTokenCalls())

func (*UseCaseMock) ValidatesToken

func (mock *UseCaseMock) ValidatesToken(ctx context.Context, tokenString string) (entities.Token, error)

ValidatesToken calls ValidatesTokenFunc.

func (*UseCaseMock) ValidatesTokenCalls

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

ValidatesTokenCalls gets all the calls that were made to ValidatesToken. Check the length with:

len(mockedUseCase.ValidatesTokenCalls())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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