Documentation
¶
Index ¶
- type DataStoreMock
- func (mock *DataStoreMock) AddBook(ctx context.Context, book *models.Book) error
- func (mock *DataStoreMock) AddBookCalls() []struct{ ... }
- func (mock *DataStoreMock) AddReview(ctx context.Context, review *models.Review) error
- func (mock *DataStoreMock) AddReviewCalls() []struct{ ... }
- func (mock *DataStoreMock) Close(ctx context.Context) error
- func (mock *DataStoreMock) CloseCalls() []struct{ ... }
- func (mock *DataStoreMock) GetBook(ctx context.Context, id string) (*models.Book, error)
- func (mock *DataStoreMock) GetBookCalls() []struct{ ... }
- func (mock *DataStoreMock) GetBooks(ctx context.Context) (models.Books, error)
- func (mock *DataStoreMock) GetBooksCalls() []struct{ ... }
- func (mock *DataStoreMock) GetReview(ctx context.Context, reviewID string) (*models.Review, error)
- func (mock *DataStoreMock) GetReviewCalls() []struct{ ... }
- func (mock *DataStoreMock) GetReviews(ctx context.Context, bookID string) (models.Reviews, error)
- func (mock *DataStoreMock) GetReviewsCalls() []struct{ ... }
- func (mock *DataStoreMock) Init(in1 config.MongoConfig) error
- func (mock *DataStoreMock) InitCalls() []struct{ ... }
- func (mock *DataStoreMock) UpdateReview(ctx context.Context, reviewID string, review *models.Review) error
- func (mock *DataStoreMock) UpdateReviewCalls() []struct{ ... }
- type HTTPServerMock
- type HealthCheckerMock
- func (mock *HealthCheckerMock) AddCheck(name string, checker healthcheck.Checker) error
- func (mock *HealthCheckerMock) AddCheckCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
- func (mock *HealthCheckerMock) HandlerCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Start(ctx context.Context)
- func (mock *HealthCheckerMock) StartCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Stop()
- func (mock *HealthCheckerMock) StopCalls() []struct{}
- type InitialiserMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataStoreMock ¶ added in v1.10.0
type DataStoreMock struct {
// AddBookFunc mocks the AddBook method.
AddBookFunc func(ctx context.Context, book *models.Book) error
// AddReviewFunc mocks the AddReview method.
AddReviewFunc func(ctx context.Context, review *models.Review) error
// CloseFunc mocks the Close method.
CloseFunc func(ctx context.Context) error
// GetBookFunc mocks the GetBook method.
GetBookFunc func(ctx context.Context, id string) (*models.Book, error)
// GetBooksFunc mocks the GetBooks method.
GetBooksFunc func(ctx context.Context) (models.Books, error)
// GetReviewFunc mocks the GetReview method.
GetReviewFunc func(ctx context.Context, reviewID string) (*models.Review, error)
// GetReviewsFunc mocks the GetReviews method.
GetReviewsFunc func(ctx context.Context, bookID string) (models.Reviews, error)
// InitFunc mocks the Init method.
InitFunc func(in1 config.MongoConfig) error
// UpdateReviewFunc mocks the UpdateReview method.
UpdateReviewFunc func(ctx context.Context, reviewID string, review *models.Review) error
// contains filtered or unexported fields
}
DataStoreMock is a mock implementation of interfaces.DataStore.
func TestSomethingThatUsesDataStore(t *testing.T) {
// make and configure a mocked interfaces.DataStore
mockedDataStore := &DataStoreMock{
AddBookFunc: func(ctx context.Context, book *models.Book) error {
panic("mock out the AddBook method")
},
AddReviewFunc: func(ctx context.Context, review *models.Review) error {
panic("mock out the AddReview method")
},
CloseFunc: func(ctx context.Context) error {
panic("mock out the Close method")
},
GetBookFunc: func(ctx context.Context, id string) (*models.Book, error) {
panic("mock out the GetBook method")
},
GetBooksFunc: func(ctx context.Context) (models.Books, error) {
panic("mock out the GetBooks method")
},
GetReviewFunc: func(ctx context.Context, reviewID string) (*models.Review, error) {
panic("mock out the GetReview method")
},
GetReviewsFunc: func(ctx context.Context, bookID string) (models.Reviews, error) {
panic("mock out the GetReviews method")
},
InitFunc: func(in1 config.MongoConfig) error {
panic("mock out the Init method")
},
UpdateReviewFunc: func(ctx context.Context, reviewID string, review *models.Review) error {
panic("mock out the UpdateReview method")
},
}
// use mockedDataStore in code that requires interfaces.DataStore
// and then make assertions.
}
func (*DataStoreMock) AddBookCalls ¶ added in v1.10.0
func (mock *DataStoreMock) AddBookCalls() []struct { Ctx context.Context Book *models.Book }
AddBookCalls gets all the calls that were made to AddBook. Check the length with:
len(mockedDataStore.AddBookCalls())
func (*DataStoreMock) AddReviewCalls ¶ added in v1.10.0
func (mock *DataStoreMock) AddReviewCalls() []struct { Ctx context.Context Review *models.Review }
AddReviewCalls gets all the calls that were made to AddReview. Check the length with:
len(mockedDataStore.AddReviewCalls())
func (*DataStoreMock) Close ¶ added in v1.10.0
func (mock *DataStoreMock) Close(ctx context.Context) error
Close calls CloseFunc.
func (*DataStoreMock) CloseCalls ¶ added in v1.10.0
func (mock *DataStoreMock) CloseCalls() []struct { Ctx context.Context }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedDataStore.CloseCalls())
func (*DataStoreMock) GetBookCalls ¶ added in v1.10.0
func (mock *DataStoreMock) GetBookCalls() []struct { Ctx context.Context ID string }
GetBookCalls gets all the calls that were made to GetBook. Check the length with:
len(mockedDataStore.GetBookCalls())
func (*DataStoreMock) GetBooksCalls ¶ added in v1.10.0
func (mock *DataStoreMock) GetBooksCalls() []struct { Ctx context.Context }
GetBooksCalls gets all the calls that were made to GetBooks. Check the length with:
len(mockedDataStore.GetBooksCalls())
func (*DataStoreMock) GetReviewCalls ¶ added in v1.10.0
func (mock *DataStoreMock) GetReviewCalls() []struct { Ctx context.Context ReviewID string }
GetReviewCalls gets all the calls that were made to GetReview. Check the length with:
len(mockedDataStore.GetReviewCalls())
func (*DataStoreMock) GetReviews ¶ added in v1.10.0
GetReviews calls GetReviewsFunc.
func (*DataStoreMock) GetReviewsCalls ¶ added in v1.10.0
func (mock *DataStoreMock) GetReviewsCalls() []struct { Ctx context.Context BookID string }
GetReviewsCalls gets all the calls that were made to GetReviews. Check the length with:
len(mockedDataStore.GetReviewsCalls())
func (*DataStoreMock) Init ¶ added in v1.10.0
func (mock *DataStoreMock) Init(in1 config.MongoConfig) error
Init calls InitFunc.
func (*DataStoreMock) InitCalls ¶ added in v1.10.0
func (mock *DataStoreMock) InitCalls() []struct { In1 config.MongoConfig }
InitCalls gets all the calls that were made to Init. Check the length with:
len(mockedDataStore.InitCalls())
func (*DataStoreMock) UpdateReview ¶ added in v1.10.0
func (mock *DataStoreMock) UpdateReview(ctx context.Context, reviewID string, review *models.Review) error
UpdateReview calls UpdateReviewFunc.
func (*DataStoreMock) UpdateReviewCalls ¶ added in v1.10.0
func (mock *DataStoreMock) UpdateReviewCalls() []struct { Ctx context.Context ReviewID string Review *models.Review }
UpdateReviewCalls gets all the calls that were made to UpdateReview. Check the length with:
len(mockedDataStore.UpdateReviewCalls())
type HTTPServerMock ¶
type HTTPServerMock struct {
// ListenAndServeFunc mocks the ListenAndServe method.
ListenAndServeFunc func() error
// contains filtered or unexported fields
}
HTTPServerMock is a mock implementation of interfaces.HTTPServer.
func TestSomethingThatUsesHTTPServer(t *testing.T) {
// make and configure a mocked interfaces.HTTPServer
mockedHTTPServer := &HTTPServerMock{
ListenAndServeFunc: func() error {
panic("mock out the ListenAndServe method")
},
}
// use mockedHTTPServer in code that requires interfaces.HTTPServer
// and then make assertions.
}
func (*HTTPServerMock) ListenAndServe ¶
func (mock *HTTPServerMock) ListenAndServe() error
ListenAndServe calls ListenAndServeFunc.
func (*HTTPServerMock) ListenAndServeCalls ¶
func (mock *HTTPServerMock) ListenAndServeCalls() []struct { }
ListenAndServeCalls gets all the calls that were made to ListenAndServe. Check the length with:
len(mockedHTTPServer.ListenAndServeCalls())
type HealthCheckerMock ¶
type HealthCheckerMock struct {
// AddCheckFunc mocks the AddCheck method.
AddCheckFunc func(name string, checker healthcheck.Checker) error
// HandlerFunc mocks the Handler method.
HandlerFunc func(w http.ResponseWriter, req *http.Request)
// StartFunc mocks the Start method.
StartFunc func(ctx context.Context)
// StopFunc mocks the Stop method.
StopFunc func()
// contains filtered or unexported fields
}
HealthCheckerMock is a mock implementation of interfaces.HealthChecker.
func TestSomethingThatUsesHealthChecker(t *testing.T) {
// make and configure a mocked interfaces.HealthChecker
mockedHealthChecker := &HealthCheckerMock{
AddCheckFunc: func(name string, checker healthcheck.Checker) error {
panic("mock out the AddCheck method")
},
HandlerFunc: func(w http.ResponseWriter, req *http.Request) {
panic("mock out the Handler method")
},
StartFunc: func(ctx context.Context) {
panic("mock out the Start method")
},
StopFunc: func() {
panic("mock out the Stop method")
},
}
// use mockedHealthChecker in code that requires interfaces.HealthChecker
// and then make assertions.
}
func (*HealthCheckerMock) AddCheck ¶
func (mock *HealthCheckerMock) AddCheck(name string, checker healthcheck.Checker) error
AddCheck calls AddCheckFunc.
func (*HealthCheckerMock) AddCheckCalls ¶
func (mock *HealthCheckerMock) AddCheckCalls() []struct { Name string Checker healthcheck.Checker }
AddCheckCalls gets all the calls that were made to AddCheck. Check the length with:
len(mockedHealthChecker.AddCheckCalls())
func (*HealthCheckerMock) Handler ¶
func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
Handler calls HandlerFunc.
func (*HealthCheckerMock) HandlerCalls ¶
func (mock *HealthCheckerMock) HandlerCalls() []struct { W http.ResponseWriter Req *http.Request }
HandlerCalls gets all the calls that were made to Handler. Check the length with:
len(mockedHealthChecker.HandlerCalls())
func (*HealthCheckerMock) Start ¶
func (mock *HealthCheckerMock) Start(ctx context.Context)
Start calls StartFunc.
func (*HealthCheckerMock) StartCalls ¶
func (mock *HealthCheckerMock) StartCalls() []struct { Ctx context.Context }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedHealthChecker.StartCalls())
func (*HealthCheckerMock) StopCalls ¶
func (mock *HealthCheckerMock) StopCalls() []struct { }
StopCalls gets all the calls that were made to Stop. Check the length with:
len(mockedHealthChecker.StopCalls())
type InitialiserMock ¶
type InitialiserMock struct {
// GetHTTPServerFunc mocks the GetHTTPServer method.
GetHTTPServerFunc func(BindAddr string, router http.Handler) interfaces.HTTPServer
// contains filtered or unexported fields
}
InitialiserMock is a mock implementation of interfaces.Initialiser.
func TestSomethingThatUsesInitialiser(t *testing.T) {
// make and configure a mocked interfaces.Initialiser
mockedInitialiser := &InitialiserMock{
GetHTTPServerFunc: func(BindAddr string, router http.Handler) interfaces.HTTPServer {
panic("mock out the GetHTTPServer method")
},
}
// use mockedInitialiser in code that requires interfaces.Initialiser
// and then make assertions.
}
func (*InitialiserMock) GetHTTPServer ¶
func (mock *InitialiserMock) GetHTTPServer(BindAddr string, router http.Handler) interfaces.HTTPServer
GetHTTPServer calls GetHTTPServerFunc.
func (*InitialiserMock) GetHTTPServerCalls ¶
func (mock *InitialiserMock) GetHTTPServerCalls() []struct { BindAddr string Router http.Handler }
GetHTTPServerCalls gets all the calls that were made to GetHTTPServer. Check the length with:
len(mockedInitialiser.GetHTTPServerCalls())