mocks

package
v0.0.0-...-5edb3c8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserRepositoryMock

type UserRepositoryMock struct {
	// LookupFunc mocks the Lookup method.
	LookupFunc func(id int64) (cleanarch.User, error)

	// StoreFunc mocks the Store method.
	StoreFunc func(user cleanarch.User) (int64, error)
	// contains filtered or unexported fields
}

UserRepositoryMock is a mock implementation of cleanarch.UserRepository.

func TestSomethingThatUsesUserRepository(t *testing.T) {

	// make and configure a mocked cleanarch.UserRepository
	mockedUserRepository := &UserRepositoryMock{
		LookupFunc: func(id int64) (cleanarch.User, error) {
			panic("mock out the Lookup method")
		},
		StoreFunc: func(user cleanarch.User) (int64, error) {
			panic("mock out the Store method")
		},
	}

	// use mockedUserRepository in code that requires cleanarch.UserRepository
	// and then make assertions.

}

func (*UserRepositoryMock) Lookup

func (mock *UserRepositoryMock) Lookup(id int64) (cleanarch.User, error)

Lookup calls LookupFunc.

func (*UserRepositoryMock) LookupCalls

func (mock *UserRepositoryMock) LookupCalls() []struct {
	ID int64
}

LookupCalls gets all the calls that were made to Lookup. Check the length with:

len(mockedUserRepository.LookupCalls())

func (*UserRepositoryMock) Store

func (mock *UserRepositoryMock) Store(user cleanarch.User) (int64, error)

Store calls StoreFunc.

func (*UserRepositoryMock) StoreCalls

func (mock *UserRepositoryMock) StoreCalls() []struct {
	User cleanarch.User
}

StoreCalls gets all the calls that were made to Store. Check the length with:

len(mockedUserRepository.StoreCalls())

Jump to

Keyboard shortcuts

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