mockuploads

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

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

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) ReadFile

func (mock *UploadManagerMock) ReadFile(ctx context.Context, path string) ([]byte, error)

ReadFile calls ReadFileFunc.

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) SaveFile

func (mock *UploadManagerMock) SaveFile(ctx context.Context, path string, content []byte) error

SaveFile calls SaveFileFunc.

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())

Jump to

Keyboard shortcuts

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