Skip to content

Commit

Permalink
test: add mock for delete all books interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jeamon committed Nov 10, 2023
1 parent 295bcba commit 471250b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests.mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
// This file contains mocks definitions needed to perform unit tests.

type MockBookStorage struct {
AddFunc func(ctx context.Context, id string, book Book) error
GetOneFunc func(ctx context.Context, id string) (Book, error)
DeleteFunc func(ctx context.Context, id string) error
UpdateFunc func(ctx context.Context, id string, book Book) (Book, error)
GetAllFunc func(ctx context.Context) ([]Book, error)
AddFunc func(ctx context.Context, id string, book Book) error
GetOneFunc func(ctx context.Context, id string) (Book, error)
DeleteFunc func(ctx context.Context, id string) error
UpdateFunc func(ctx context.Context, id string, book Book) (Book, error)
GetAllFunc func(ctx context.Context) ([]Book, error)
DeleteAllFunc func(ctx context.Context) error
}

// Add mocks the behavior of book creation by the repository.
Expand Down Expand Up @@ -40,6 +41,11 @@ func (m *MockBookStorage) GetAll(ctx context.Context) ([]Book, error) {
return m.GetAllFunc(ctx)
}

// DeleteAll mocks the behavior of deleting all books by the repository.
func (m *MockBookStorage) DeleteAll(ctx context.Context) error {
return m.DeleteAllFunc(ctx)
}

// MockClocker implements a fake Clocker.
type MockClocker struct {
MockNow time.Time
Expand Down

0 comments on commit 471250b

Please sign in to comment.