Documentation
¶
Overview ¶
Package mockuploads provides mock implementations of the uploads package's interfaces. Both the hand-written testify-based MockUploadManager and the moq-generated UploadManagerMock live here during the testify → moq migration. New test code should prefer UploadManagerMock.
Index ¶
- type UploadManagerMock
- func (mock *UploadManagerMock) ReadFile(ctx context.Context, path string) ([]byte, error)
- func (mock *UploadManagerMock) ReadFileCalls() []struct{ ... }
- func (mock *UploadManagerMock) SaveFile(ctx context.Context, path string, content []byte) error
- func (mock *UploadManagerMock) SaveFileCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UploadManagerMock ¶
type UploadManagerMock struct {
// ReadFileFunc mocks the ReadFile method.
ReadFileFunc func(ctx context.Context, path string) ([]byte, error)
// SaveFileFunc mocks the SaveFile method.
SaveFileFunc func(ctx context.Context, path string, content []byte) error
// contains filtered or unexported fields
}
UploadManagerMock is a mock implementation of uploads.UploadManager.
func TestSomethingThatUsesUploadManager(t *testing.T) {
// make and configure a mocked uploads.UploadManager
mockedUploadManager := &UploadManagerMock{
ReadFileFunc: func(ctx context.Context, path string) ([]byte, error) {
panic("mock out the ReadFile method")
},
SaveFileFunc: func(ctx context.Context, path string, content []byte) error {
panic("mock out the SaveFile method")
},
}
// use mockedUploadManager in code that requires uploads.UploadManager
// and then make assertions.
}
func (*UploadManagerMock) ReadFileCalls ¶
func (mock *UploadManagerMock) ReadFileCalls() []struct { Ctx context.Context Path string }
ReadFileCalls gets all the calls that were made to ReadFile. Check the length with:
len(mockedUploadManager.ReadFileCalls())
func (*UploadManagerMock) SaveFileCalls ¶
func (mock *UploadManagerMock) SaveFileCalls() []struct { Ctx context.Context Path string Content []byte }
SaveFileCalls gets all the calls that were made to SaveFile. Check the length with:
len(mockedUploadManager.SaveFileCalls())
Click to show internal directories.
Click to hide internal directories.