mock

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 2 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailSenderMock

type EmailSenderMock struct {
	// SendFunc mocks the Send method.
	SendFunc func(from string, to []string, msg []byte) error
	// contains filtered or unexported fields
}

EmailSenderMock is a mock implementation of api.EmailSender.

func TestSomethingThatUsesEmailSender(t *testing.T) {

	// make and configure a mocked api.EmailSender
	mockedEmailSender := &EmailSenderMock{
		SendFunc: func(from string, to []string, msg []byte) error {
			panic("mock out the Send method")
		},
	}

	// use mockedEmailSender in code that requires api.EmailSender
	// and then make assertions.

}

func (*EmailSenderMock) Send

func (mock *EmailSenderMock) Send(from string, to []string, msg []byte) error

Send calls SendFunc.

func (*EmailSenderMock) SendCalls

func (mock *EmailSenderMock) SendCalls() []struct {
	From string
	To   []string
	Msg  []byte
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedEmailSender.SendCalls())

Jump to

Keyboard shortcuts

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