mocks

package
v0.0.0-...-7dfcc7c Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Options = struct {
	RepositoryGetUser     map[string]repositoryGetUserValues
	RepositoryIsUserValid map[string]repositoryIsUserValidValues
}{

	RepositoryGetUser: map[string]repositoryGetUserValues{
		"none": {
			UserID:   0,
			Response: &core.User{},
			Error:    nil,
		},
		"default": {
			UserID:   1,
			Response: &core.User{ID: 1, Username: "gilperopiola"},
			Error:    nil,
		},
		"err_not_found": {
			UserID:   0,
			Response: &core.User{},
			Error:    fmt.Errorf("user not found"),
		},
	},

	RepositoryIsUserValid: map[string]repositoryIsUserValidValues{
		"valid": {
			UserID: 1,
			Valid:  true,
		},
		"invalid": {
			UserID: 1,
			Valid:  false,
		},
	},
}

Options holds all of the different cases each mock function will handle.

Functions

This section is empty.

Types

type RepositoryMock

type RepositoryMock struct {
	*mock.Mock
}

RepositoryMock is a mock of Repository interface.

func NewRepositoryMock

func NewRepositoryMock() *RepositoryMock

NewRepositoryMock returns a new mock of the Repository interface.

func SetupRepositoryWithGetUser

func SetupRepositoryWithGetUser(option string) *RepositoryMock

func SetupRepositoryWithIsUserValid

func SetupRepositoryWithIsUserValid(mock *RepositoryMock, option string) *RepositoryMock

SetupRepositoryWithIsUserValid takes a mock as parameter because a previous mocked call to the GetUser method is needed.

func (*RepositoryMock) GetUser

func (m *RepositoryMock) GetUser(id int) (*core.User, error)

func (*RepositoryMock) IsUserValid

func (m *RepositoryMock) IsUserValid(id int) bool

Jump to

Keyboard shortcuts

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