Documentation ¶
Index ¶
- Variables
- func CreateRequestWithAuth(method, URL string, body io.Reader) (*http.Request, error)
- func CreateRequestWithOutAuth(method, URL string, body io.Reader) (*http.Request, error)
- type JobServiceMock
- func (mock *JobServiceMock) CreateJob(ctx context.Context, job *models.Job) (*models.Job, error)
- func (mock *JobServiceMock) CreateJobCalls() []struct{ ... }
- func (mock *JobServiceMock) UpdateJob(ctx context.Context, jobID string, job *models.Job) error
- func (mock *JobServiceMock) UpdateJobCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Dstore = mockdatastore.DataStorer{} DstoreNotFound = mockdatastore.DataStorer{NotFound: true} DstoreInternalError = mockdatastore.DataStorer{InternalError: true} )
List of mocked datastores returning different results
Functions ¶
func CreateRequestWithAuth ¶
CreateRequestWithAuth adds authentication to request
Types ¶
type JobServiceMock ¶
type JobServiceMock struct { // CreateJobFunc mocks the CreateJob method. CreateJobFunc func(ctx context.Context, job *models.Job) (*models.Job, error) // UpdateJobFunc mocks the UpdateJob method. UpdateJobFunc func(ctx context.Context, jobID string, job *models.Job) error // contains filtered or unexported fields }
JobServiceMock is a mock implementation of api.JobService.
func TestSomethingThatUsesJobService(t *testing.T) { // make and configure a mocked api.JobService mockedJobService := &JobServiceMock{ CreateJobFunc: func(ctx context.Context, job *models.Job) (*models.Job, error) { panic("mock out the CreateJob method") }, UpdateJobFunc: func(ctx context.Context, jobID string, job *models.Job) error { panic("mock out the UpdateJob method") }, } // use mockedJobService in code that requires api.JobService // and then make assertions. }
func (*JobServiceMock) CreateJobCalls ¶
func (mock *JobServiceMock) CreateJobCalls() []struct { Ctx context.Context Job *models.Job }
CreateJobCalls gets all the calls that were made to CreateJob. Check the length with:
len(mockedJobService.CreateJobCalls())
func (*JobServiceMock) UpdateJobCalls ¶
func (mock *JobServiceMock) UpdateJobCalls() []struct { Ctx context.Context JobID string Job *models.Job }
UpdateJobCalls gets all the calls that were made to UpdateJob. Check the length with:
len(mockedJobService.UpdateJobCalls())
Click to show internal directories.
Click to hide internal directories.