mock

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerMock

type HandlerMock struct {
	// HandleFunc mocks the Handle method.
	HandleFunc func(ctx context.Context, contentPublished *models.ContentPublished, cfg config.Config) error
	// contains filtered or unexported fields
}

HandlerMock is a mock implementation of event.Handler.

    func TestSomethingThatUsesHandler(t *testing.T) {

        // make and configure a mocked event.Handler
        mockedHandler := &HandlerMock{
            HandleFunc: func(ctx context.Context, contentPublished *models.ContentPublished, cfg config.Config) error {
	               panic("mock out the Handle method")
            },
        }

        // use mockedHandler in code that requires event.Handler
        // and then make assertions.

    }

func (*HandlerMock) Handle

func (mock *HandlerMock) Handle(ctx context.Context, contentPublished *models.ContentPublished, cfg config.Config) error

Handle calls HandleFunc.

func (*HandlerMock) HandleCalls

func (mock *HandlerMock) HandleCalls() []struct {
	Ctx              context.Context
	ContentPublished *models.ContentPublished
	Cfg              config.Config
}

HandleCalls gets all the calls that were made to Handle. Check the length with:

len(mockedHandler.HandleCalls())

type MarshallerMock added in v0.2.0

type MarshallerMock struct {
	// MarshalFunc mocks the Marshal method.
	MarshalFunc func(s interface{}) ([]byte, error)
	// contains filtered or unexported fields
}

MarshallerMock is a mock implementation of event.Marshaller.

    func TestSomethingThatUsesMarshaller(t *testing.T) {

        // make and configure a mocked event.Marshaller
        mockedMarshaller := &MarshallerMock{
            MarshalFunc: func(s interface{}) ([]byte, error) {
	               panic("mock out the Marshal method")
            },
        }

        // use mockedMarshaller in code that requires event.Marshaller
        // and then make assertions.

    }

func (*MarshallerMock) Marshal added in v0.2.0

func (mock *MarshallerMock) Marshal(s interface{}) ([]byte, error)

Marshal calls MarshalFunc.

func (*MarshallerMock) MarshalCalls added in v0.2.0

func (mock *MarshallerMock) MarshalCalls() []struct {
	S interface{}
}

MarshalCalls gets all the calls that were made to Marshal. Check the length with:

len(mockedMarshaller.MarshalCalls())

Jump to

Keyboard shortcuts

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