mock

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 2 Imported by: 0

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