mocks

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeckRepoMock

type DeckRepoMock struct {
	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, item domain.Deck) error

	// FilterFunc mocks the Filter method.
	FilterFunc func(ctx context.Context, filterFunc func(domain.Deck) bool) ([]domain.Deck, error)

	// FindFunc mocks the Find method.
	FindFunc func(ctx context.Context, findFunc func(domain.Deck) bool) (*domain.Deck, error)

	// ListAllFunc mocks the ListAll method.
	ListAllFunc func(ctx context.Context) ([]domain.Deck, error)

	// SaveFunc mocks the Save method.
	SaveFunc func(ctx context.Context, item domain.Deck) (*domain.Deck, error)
	// contains filtered or unexported fields
}

DeckRepoMock is a mock implementation of storage.DeckRepo.

func TestSomethingThatUsesDeckRepo(t *testing.T) {

	// make and configure a mocked storage.DeckRepo
	mockedDeckRepo := &DeckRepoMock{
		DeleteFunc: func(ctx context.Context, item domain.Deck) error {
			panic("mock out the Delete method")
		},
		FilterFunc: func(ctx context.Context, filterFunc func(domain.Deck) bool) ([]domain.Deck, error) {
			panic("mock out the Filter method")
		},
		FindFunc: func(ctx context.Context, findFunc func(domain.Deck) bool) (*domain.Deck, error) {
			panic("mock out the Find method")
		},
		ListAllFunc: func(ctx context.Context) ([]domain.Deck, error) {
			panic("mock out the ListAll method")
		},
		SaveFunc: func(ctx context.Context, item domain.Deck) (*domain.Deck, error) {
			panic("mock out the Save method")
		},
	}

	// use mockedDeckRepo in code that requires storage.DeckRepo
	// and then make assertions.

}

func (*DeckRepoMock) Delete

func (mock *DeckRepoMock) Delete(ctx context.Context, item domain.Deck) error

Delete calls DeleteFunc.

func (*DeckRepoMock) DeleteCalls

func (mock *DeckRepoMock) DeleteCalls() []struct {
	Ctx  context.Context
	Item domain.Deck
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedDeckRepo.DeleteCalls())

func (*DeckRepoMock) Filter

func (mock *DeckRepoMock) Filter(ctx context.Context, filterFunc func(domain.Deck) bool) ([]domain.Deck, error)

Filter calls FilterFunc.

func (*DeckRepoMock) FilterCalls

func (mock *DeckRepoMock) FilterCalls() []struct {
	Ctx        context.Context
	FilterFunc func(domain.Deck) bool
}

FilterCalls gets all the calls that were made to Filter. Check the length with:

len(mockedDeckRepo.FilterCalls())

func (*DeckRepoMock) Find

func (mock *DeckRepoMock) Find(ctx context.Context, findFunc func(domain.Deck) bool) (*domain.Deck, error)

Find calls FindFunc.

func (*DeckRepoMock) FindCalls

func (mock *DeckRepoMock) FindCalls() []struct {
	Ctx      context.Context
	FindFunc func(domain.Deck) bool
}

FindCalls gets all the calls that were made to Find. Check the length with:

len(mockedDeckRepo.FindCalls())

func (*DeckRepoMock) ListAll

func (mock *DeckRepoMock) ListAll(ctx context.Context) ([]domain.Deck, error)

ListAll calls ListAllFunc.

func (*DeckRepoMock) ListAllCalls

func (mock *DeckRepoMock) ListAllCalls() []struct {
	Ctx context.Context
}

ListAllCalls gets all the calls that were made to ListAll. Check the length with:

len(mockedDeckRepo.ListAllCalls())

func (*DeckRepoMock) Save

func (mock *DeckRepoMock) Save(ctx context.Context, item domain.Deck) (*domain.Deck, error)

Save calls SaveFunc.

func (*DeckRepoMock) SaveCalls

func (mock *DeckRepoMock) SaveCalls() []struct {
	Ctx  context.Context
	Item domain.Deck
}

SaveCalls gets all the calls that were made to Save. Check the length with:

len(mockedDeckRepo.SaveCalls())

type FlashcardServiceMock

type FlashcardServiceMock struct {
	// DeleteDeckByNameFunc mocks the DeleteDeckByName method.
	DeleteDeckByNameFunc func(name string) error

	// FindCardsByWordFunc mocks the FindCardsByWord method.
	FindCardsByWordFunc func(word string) ([]domain.Card, error)

	// FindDeckByNameFunc mocks the FindDeckByName method.
	FindDeckByNameFunc func(name string) (*domain.Deck, error)

	// GetStorageFunc mocks the GetStorage method.
	GetStorageFunc func() *storage.Storage

	// ListAllCardsFunc mocks the ListAllCards method.
	ListAllCardsFunc func(inDeck domain.Deck) ([]domain.Card, error)

	// ListAllDecksFunc mocks the ListAllDecks method.
	ListAllDecksFunc func() ([]domain.Deck, error)

	// SaveCardFunc mocks the SaveCard method.
	SaveCardFunc func(card domain.Card) (*domain.Card, error)

	// SaveDeckFunc mocks the SaveDeck method.
	SaveDeckFunc func(deck domain.Deck) (*domain.Deck, error)
	// contains filtered or unexported fields
}

FlashcardServiceMock is a mock implementation of service.FlashcardService.

func TestSomethingThatUsesFlashcardService(t *testing.T) {

	// make and configure a mocked service.FlashcardService
	mockedFlashcardService := &FlashcardServiceMock{
		DeleteDeckByNameFunc: func(name string) error {
			panic("mock out the DeleteDeckByName method")
		},
		FindCardsByWordFunc: func(word string) ([]domain.Card, error) {
			panic("mock out the FindCardsByWord method")
		},
		FindDeckByNameFunc: func(name string) (*domain.Deck, error) {
			panic("mock out the FindDeckByName method")
		},
		GetStorageFunc: func() *storage.Storage {
			panic("mock out the GetStorage method")
		},
		ListAllCardsFunc: func(inDeck domain.Deck) ([]domain.Card, error) {
			panic("mock out the ListAllCards method")
		},
		ListAllDecksFunc: func() ([]domain.Deck, error) {
			panic("mock out the ListAllDecks method")
		},
		SaveCardFunc: func(card domain.Card) (*domain.Card, error) {
			panic("mock out the SaveCard method")
		},
		SaveDeckFunc: func(deck domain.Deck) (*domain.Deck, error) {
			panic("mock out the SaveDeck method")
		},
	}

	// use mockedFlashcardService in code that requires service.FlashcardService
	// and then make assertions.

}

func (*FlashcardServiceMock) DeleteDeckByName

func (mock *FlashcardServiceMock) DeleteDeckByName(name string) error

DeleteDeckByName calls DeleteDeckByNameFunc.

func (*FlashcardServiceMock) DeleteDeckByNameCalls

func (mock *FlashcardServiceMock) DeleteDeckByNameCalls() []struct {
	Name string
}

DeleteDeckByNameCalls gets all the calls that were made to DeleteDeckByName. Check the length with:

len(mockedFlashcardService.DeleteDeckByNameCalls())

func (*FlashcardServiceMock) FindCardsByWord

func (mock *FlashcardServiceMock) FindCardsByWord(word string) ([]domain.Card, error)

FindCardsByWord calls FindCardsByWordFunc.

func (*FlashcardServiceMock) FindCardsByWordCalls

func (mock *FlashcardServiceMock) FindCardsByWordCalls() []struct {
	Word string
}

FindCardsByWordCalls gets all the calls that were made to FindCardsByWord. Check the length with:

len(mockedFlashcardService.FindCardsByWordCalls())

func (*FlashcardServiceMock) FindDeckByName

func (mock *FlashcardServiceMock) FindDeckByName(name string) (*domain.Deck, error)

FindDeckByName calls FindDeckByNameFunc.

func (*FlashcardServiceMock) FindDeckByNameCalls

func (mock *FlashcardServiceMock) FindDeckByNameCalls() []struct {
	Name string
}

FindDeckByNameCalls gets all the calls that were made to FindDeckByName. Check the length with:

len(mockedFlashcardService.FindDeckByNameCalls())

func (*FlashcardServiceMock) GetStorage

func (mock *FlashcardServiceMock) GetStorage() *storage.Storage

GetStorage calls GetStorageFunc.

func (*FlashcardServiceMock) GetStorageCalls

func (mock *FlashcardServiceMock) GetStorageCalls() []struct {
}

GetStorageCalls gets all the calls that were made to GetStorage. Check the length with:

len(mockedFlashcardService.GetStorageCalls())

func (*FlashcardServiceMock) ListAllCards

func (mock *FlashcardServiceMock) ListAllCards(inDeck domain.Deck) ([]domain.Card, error)

ListAllCards calls ListAllCardsFunc.

func (*FlashcardServiceMock) ListAllCardsCalls

func (mock *FlashcardServiceMock) ListAllCardsCalls() []struct {
	InDeck domain.Deck
}

ListAllCardsCalls gets all the calls that were made to ListAllCards. Check the length with:

len(mockedFlashcardService.ListAllCardsCalls())

func (*FlashcardServiceMock) ListAllDecks

func (mock *FlashcardServiceMock) ListAllDecks() ([]domain.Deck, error)

ListAllDecks calls ListAllDecksFunc.

func (*FlashcardServiceMock) ListAllDecksCalls

func (mock *FlashcardServiceMock) ListAllDecksCalls() []struct {
}

ListAllDecksCalls gets all the calls that were made to ListAllDecks. Check the length with:

len(mockedFlashcardService.ListAllDecksCalls())

func (*FlashcardServiceMock) SaveCard

func (mock *FlashcardServiceMock) SaveCard(card domain.Card) (*domain.Card, error)

SaveCard calls SaveCardFunc.

func (*FlashcardServiceMock) SaveCardCalls

func (mock *FlashcardServiceMock) SaveCardCalls() []struct {
	Card domain.Card
}

SaveCardCalls gets all the calls that were made to SaveCard. Check the length with:

len(mockedFlashcardService.SaveCardCalls())

func (*FlashcardServiceMock) SaveDeck

func (mock *FlashcardServiceMock) SaveDeck(deck domain.Deck) (*domain.Deck, error)

SaveDeck calls SaveDeckFunc.

func (*FlashcardServiceMock) SaveDeckCalls

func (mock *FlashcardServiceMock) SaveDeckCalls() []struct {
	Deck domain.Deck
}

SaveDeckCalls gets all the calls that were made to SaveDeck. Check the length with:

len(mockedFlashcardService.SaveDeckCalls())

Jump to

Keyboard shortcuts

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