mock

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandlerMock

type ErrorHandlerMock struct {
	// ErrorToGRPCStatusFunc mocks the ErrorToGRPCStatus method.
	ErrorToGRPCStatusFunc func(err error) (*status.Status, error)

	// IsApplicationErrorFunc mocks the IsApplicationError method.
	IsApplicationErrorFunc func(err error) bool

	// LogErrorFunc mocks the LogError method.
	LogErrorFunc func(err error)

	// ReportErrorFunc mocks the ReportError method.
	ReportErrorFunc func(contextMoqParam context.Context, err error) error
	// contains filtered or unexported fields
}

ErrorHandlerMock is a mock implementation of grpc.ErrorHandler.

func TestSomethingThatUsesErrorHandler(t *testing.T) {

	// make and configure a mocked grpc.ErrorHandler
	mockedErrorHandler := &ErrorHandlerMock{
		ErrorToGRPCStatusFunc: func(err error) (*status.Status, error) {
			panic("mock out the ErrorToGRPCStatus method")
		},
		IsApplicationErrorFunc: func(err error) bool {
			panic("mock out the IsApplicationError method")
		},
		LogErrorFunc: func(err error)  {
			panic("mock out the LogError method")
		},
		ReportErrorFunc: func(contextMoqParam context.Context, err error) error {
			panic("mock out the ReportError method")
		},
	}

	// use mockedErrorHandler in code that requires grpc.ErrorHandler
	// and then make assertions.

}

func (*ErrorHandlerMock) ErrorToGRPCStatus

func (mock *ErrorHandlerMock) ErrorToGRPCStatus(err error) (*status.Status, error)

ErrorToGRPCStatus calls ErrorToGRPCStatusFunc.

func (*ErrorHandlerMock) ErrorToGRPCStatusCalls

func (mock *ErrorHandlerMock) ErrorToGRPCStatusCalls() []struct {
	Err error
}

ErrorToGRPCStatusCalls gets all the calls that were made to ErrorToGRPCStatus. Check the length with:

len(mockedErrorHandler.ErrorToGRPCStatusCalls())

func (*ErrorHandlerMock) IsApplicationError

func (mock *ErrorHandlerMock) IsApplicationError(err error) bool

IsApplicationError calls IsApplicationErrorFunc.

func (*ErrorHandlerMock) IsApplicationErrorCalls

func (mock *ErrorHandlerMock) IsApplicationErrorCalls() []struct {
	Err error
}

IsApplicationErrorCalls gets all the calls that were made to IsApplicationError. Check the length with:

len(mockedErrorHandler.IsApplicationErrorCalls())

func (*ErrorHandlerMock) LogError

func (mock *ErrorHandlerMock) LogError(err error)

LogError calls LogErrorFunc.

func (*ErrorHandlerMock) LogErrorCalls

func (mock *ErrorHandlerMock) LogErrorCalls() []struct {
	Err error
}

LogErrorCalls gets all the calls that were made to LogError. Check the length with:

len(mockedErrorHandler.LogErrorCalls())

func (*ErrorHandlerMock) ReportError

func (mock *ErrorHandlerMock) ReportError(contextMoqParam context.Context, err error) error

ReportError calls ReportErrorFunc.

func (*ErrorHandlerMock) ReportErrorCalls

func (mock *ErrorHandlerMock) ReportErrorCalls() []struct {
	ContextMoqParam context.Context
	Err             error
}

ReportErrorCalls gets all the calls that were made to ReportError. Check the length with:

len(mockedErrorHandler.ReportErrorCalls())

type MonitorOperationerMock

type MonitorOperationerMock struct {
	// MonitorOperationFunc mocks the MonitorOperation method.
	MonitorOperationFunc func(ctx context.Context, name string, traceID [16]byte, operationFunc func(context.Context))
	// contains filtered or unexported fields
}

MonitorOperationerMock is a mock implementation of grpc.MonitorOperationer.

func TestSomethingThatUsesMonitorOperationer(t *testing.T) {

	// make and configure a mocked grpc.MonitorOperationer
	mockedMonitorOperationer := &MonitorOperationerMock{
		MonitorOperationFunc: func(ctx context.Context, name string, traceID [16]byte, operationFunc func(context.Context))  {
			panic("mock out the MonitorOperation method")
		},
	}

	// use mockedMonitorOperationer in code that requires grpc.MonitorOperationer
	// and then make assertions.

}

func (*MonitorOperationerMock) MonitorOperation

func (mock *MonitorOperationerMock) MonitorOperation(ctx context.Context, name string, traceID [16]byte, operationFunc func(context.Context))

MonitorOperation calls MonitorOperationFunc.

func (*MonitorOperationerMock) MonitorOperationCalls

func (mock *MonitorOperationerMock) MonitorOperationCalls() []struct {
	Ctx           context.Context
	Name          string
	TraceID       [16]byte
	OperationFunc func(context.Context)
}

MonitorOperationCalls gets all the calls that were made to MonitorOperation. Check the length with:

len(mockedMonitorOperationer.MonitorOperationCalls())

type PanicHandlerMock

type PanicHandlerMock struct {
	// LogErrorFunc mocks the LogError method.
	LogErrorFunc func(err error)

	// LogPanicFunc mocks the LogPanic method.
	LogPanicFunc func(ifaceVal any)

	// ReportPanicFunc mocks the ReportPanic method.
	ReportPanicFunc func(contextMoqParam context.Context, ifaceVal any) error
	// contains filtered or unexported fields
}

PanicHandlerMock is a mock implementation of grpc.PanicHandler.

func TestSomethingThatUsesPanicHandler(t *testing.T) {

	// make and configure a mocked grpc.PanicHandler
	mockedPanicHandler := &PanicHandlerMock{
		LogErrorFunc: func(err error)  {
			panic("mock out the LogError method")
		},
		LogPanicFunc: func(ifaceVal any)  {
			panic("mock out the LogPanic method")
		},
		ReportPanicFunc: func(contextMoqParam context.Context, ifaceVal any) error {
			panic("mock out the ReportPanic method")
		},
	}

	// use mockedPanicHandler in code that requires grpc.PanicHandler
	// and then make assertions.

}

func (*PanicHandlerMock) LogError

func (mock *PanicHandlerMock) LogError(err error)

LogError calls LogErrorFunc.

func (*PanicHandlerMock) LogErrorCalls

func (mock *PanicHandlerMock) LogErrorCalls() []struct {
	Err error
}

LogErrorCalls gets all the calls that were made to LogError. Check the length with:

len(mockedPanicHandler.LogErrorCalls())

func (*PanicHandlerMock) LogPanic

func (mock *PanicHandlerMock) LogPanic(ifaceVal any)

LogPanic calls LogPanicFunc.

func (*PanicHandlerMock) LogPanicCalls

func (mock *PanicHandlerMock) LogPanicCalls() []struct {
	IfaceVal any
}

LogPanicCalls gets all the calls that were made to LogPanic. Check the length with:

len(mockedPanicHandler.LogPanicCalls())

func (*PanicHandlerMock) ReportPanic

func (mock *PanicHandlerMock) ReportPanic(contextMoqParam context.Context, ifaceVal any) error

ReportPanic calls ReportPanicFunc.

func (*PanicHandlerMock) ReportPanicCalls

func (mock *PanicHandlerMock) ReportPanicCalls() []struct {
	ContextMoqParam context.Context
	IfaceVal        any
}

ReportPanicCalls gets all the calls that were made to ReportPanic. Check the length with:

len(mockedPanicHandler.ReportPanicCalls())

Jump to

Keyboard shortcuts

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