mockuploads

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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