Documentation
¶
Overview ¶
Package mockencoding provides moq-generated mocks for the encoding package.
Index ¶
- type ClientEncoderMock
- func (mock *ClientEncoderMock) ContentType() string
- func (mock *ClientEncoderMock) ContentTypeCalls() []struct{}
- func (mock *ClientEncoderMock) Encode(ctx context.Context, dest io.Writer, v any) error
- func (mock *ClientEncoderMock) EncodeCalls() []struct{ ... }
- func (mock *ClientEncoderMock) EncodeReader(ctx context.Context, data any) (io.Reader, error)
- func (mock *ClientEncoderMock) EncodeReaderCalls() []struct{ ... }
- func (mock *ClientEncoderMock) Unmarshal(ctx context.Context, data []byte, v any) error
- func (mock *ClientEncoderMock) UnmarshalCalls() []struct{ ... }
- type ServerEncoderDecoderMock
- func (mock *ServerEncoderDecoderMock) DecodeBytes(ctx context.Context, payload []byte, dest any) error
- func (mock *ServerEncoderDecoderMock) DecodeBytesCalls() []struct{ ... }
- func (mock *ServerEncoderDecoderMock) DecodeRequest(ctx context.Context, req *http.Request, dest any) error
- func (mock *ServerEncoderDecoderMock) DecodeRequestCalls() []struct{ ... }
- func (mock *ServerEncoderDecoderMock) EncodeResponseWithStatus(ctx context.Context, res http.ResponseWriter, val any, statusCode int)
- func (mock *ServerEncoderDecoderMock) EncodeResponseWithStatusCalls() []struct{ ... }
- func (mock *ServerEncoderDecoderMock) MustEncode(ctx context.Context, v any) []byte
- func (mock *ServerEncoderDecoderMock) MustEncodeCalls() []struct{ ... }
- func (mock *ServerEncoderDecoderMock) MustEncodeJSON(ctx context.Context, v any) []byte
- func (mock *ServerEncoderDecoderMock) MustEncodeJSONCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientEncoderMock ¶
type ClientEncoderMock struct {
// ContentTypeFunc mocks the ContentType method.
ContentTypeFunc func() string
// EncodeFunc mocks the Encode method.
EncodeFunc func(ctx context.Context, dest io.Writer, v any) error
// EncodeReaderFunc mocks the EncodeReader method.
EncodeReaderFunc func(ctx context.Context, data any) (io.Reader, error)
// UnmarshalFunc mocks the Unmarshal method.
UnmarshalFunc func(ctx context.Context, data []byte, v any) error
// contains filtered or unexported fields
}
ClientEncoderMock is a mock implementation of encoding.ClientEncoder.
func TestSomethingThatUsesClientEncoder(t *testing.T) {
// make and configure a mocked encoding.ClientEncoder
mockedClientEncoder := &ClientEncoderMock{
ContentTypeFunc: func() string {
panic("mock out the ContentType method")
},
EncodeFunc: func(ctx context.Context, dest io.Writer, v any) error {
panic("mock out the Encode method")
},
EncodeReaderFunc: func(ctx context.Context, data any) (io.Reader, error) {
panic("mock out the EncodeReader method")
},
UnmarshalFunc: func(ctx context.Context, data []byte, v any) error {
panic("mock out the Unmarshal method")
},
}
// use mockedClientEncoder in code that requires encoding.ClientEncoder
// and then make assertions.
}
func (*ClientEncoderMock) ContentType ¶
func (mock *ClientEncoderMock) ContentType() string
ContentType calls ContentTypeFunc.
func (*ClientEncoderMock) ContentTypeCalls ¶
func (mock *ClientEncoderMock) ContentTypeCalls() []struct { }
ContentTypeCalls gets all the calls that were made to ContentType. Check the length with:
len(mockedClientEncoder.ContentTypeCalls())
func (*ClientEncoderMock) EncodeCalls ¶
EncodeCalls gets all the calls that were made to Encode. Check the length with:
len(mockedClientEncoder.EncodeCalls())
func (*ClientEncoderMock) EncodeReader ¶
EncodeReader calls EncodeReaderFunc.
func (*ClientEncoderMock) EncodeReaderCalls ¶
func (mock *ClientEncoderMock) EncodeReaderCalls() []struct { Ctx context.Context Data any }
EncodeReaderCalls gets all the calls that were made to EncodeReader. Check the length with:
len(mockedClientEncoder.EncodeReaderCalls())
func (*ClientEncoderMock) UnmarshalCalls ¶
func (mock *ClientEncoderMock) UnmarshalCalls() []struct { Ctx context.Context Data []byte V any }
UnmarshalCalls gets all the calls that were made to Unmarshal. Check the length with:
len(mockedClientEncoder.UnmarshalCalls())
type ServerEncoderDecoderMock ¶
type ServerEncoderDecoderMock struct {
// DecodeBytesFunc mocks the DecodeBytes method.
DecodeBytesFunc func(ctx context.Context, payload []byte, dest any) error
// DecodeRequestFunc mocks the DecodeRequest method.
DecodeRequestFunc func(ctx context.Context, req *http.Request, dest any) error
// EncodeResponseWithStatusFunc mocks the EncodeResponseWithStatus method.
EncodeResponseWithStatusFunc func(ctx context.Context, res http.ResponseWriter, val any, statusCode int)
// MustEncodeFunc mocks the MustEncode method.
MustEncodeFunc func(ctx context.Context, v any) []byte
// MustEncodeJSONFunc mocks the MustEncodeJSON method.
MustEncodeJSONFunc func(ctx context.Context, v any) []byte
// contains filtered or unexported fields
}
ServerEncoderDecoderMock is a mock implementation of encoding.ServerEncoderDecoder.
func TestSomethingThatUsesServerEncoderDecoder(t *testing.T) {
// make and configure a mocked encoding.ServerEncoderDecoder
mockedServerEncoderDecoder := &ServerEncoderDecoderMock{
DecodeBytesFunc: func(ctx context.Context, payload []byte, dest any) error {
panic("mock out the DecodeBytes method")
},
DecodeRequestFunc: func(ctx context.Context, req *http.Request, dest any) error {
panic("mock out the DecodeRequest method")
},
EncodeResponseWithStatusFunc: func(ctx context.Context, res http.ResponseWriter, val any, statusCode int) {
panic("mock out the EncodeResponseWithStatus method")
},
MustEncodeFunc: func(ctx context.Context, v any) []byte {
panic("mock out the MustEncode method")
},
MustEncodeJSONFunc: func(ctx context.Context, v any) []byte {
panic("mock out the MustEncodeJSON method")
},
}
// use mockedServerEncoderDecoder in code that requires encoding.ServerEncoderDecoder
// and then make assertions.
}
func (*ServerEncoderDecoderMock) DecodeBytes ¶
func (mock *ServerEncoderDecoderMock) DecodeBytes(ctx context.Context, payload []byte, dest any) error
DecodeBytes calls DecodeBytesFunc.
func (*ServerEncoderDecoderMock) DecodeBytesCalls ¶
func (mock *ServerEncoderDecoderMock) DecodeBytesCalls() []struct { Ctx context.Context Payload []byte Dest any }
DecodeBytesCalls gets all the calls that were made to DecodeBytes. Check the length with:
len(mockedServerEncoderDecoder.DecodeBytesCalls())
func (*ServerEncoderDecoderMock) DecodeRequest ¶
func (mock *ServerEncoderDecoderMock) DecodeRequest(ctx context.Context, req *http.Request, dest any) error
DecodeRequest calls DecodeRequestFunc.
func (*ServerEncoderDecoderMock) DecodeRequestCalls ¶
func (mock *ServerEncoderDecoderMock) DecodeRequestCalls() []struct { Ctx context.Context Req *http.Request Dest any }
DecodeRequestCalls gets all the calls that were made to DecodeRequest. Check the length with:
len(mockedServerEncoderDecoder.DecodeRequestCalls())
func (*ServerEncoderDecoderMock) EncodeResponseWithStatus ¶
func (mock *ServerEncoderDecoderMock) EncodeResponseWithStatus(ctx context.Context, res http.ResponseWriter, val any, statusCode int)
EncodeResponseWithStatus calls EncodeResponseWithStatusFunc.
func (*ServerEncoderDecoderMock) EncodeResponseWithStatusCalls ¶
func (mock *ServerEncoderDecoderMock) EncodeResponseWithStatusCalls() []struct { Ctx context.Context Res http.ResponseWriter Val any StatusCode int }
EncodeResponseWithStatusCalls gets all the calls that were made to EncodeResponseWithStatus. Check the length with:
len(mockedServerEncoderDecoder.EncodeResponseWithStatusCalls())
func (*ServerEncoderDecoderMock) MustEncode ¶
func (mock *ServerEncoderDecoderMock) MustEncode(ctx context.Context, v any) []byte
MustEncode calls MustEncodeFunc.
func (*ServerEncoderDecoderMock) MustEncodeCalls ¶
func (mock *ServerEncoderDecoderMock) MustEncodeCalls() []struct { Ctx context.Context V any }
MustEncodeCalls gets all the calls that were made to MustEncode. Check the length with:
len(mockedServerEncoderDecoder.MustEncodeCalls())
func (*ServerEncoderDecoderMock) MustEncodeJSON ¶
func (mock *ServerEncoderDecoderMock) MustEncodeJSON(ctx context.Context, v any) []byte
MustEncodeJSON calls MustEncodeJSONFunc.
func (*ServerEncoderDecoderMock) MustEncodeJSONCalls ¶
func (mock *ServerEncoderDecoderMock) MustEncodeJSONCalls() []struct { Ctx context.Context V any }
MustEncodeJSONCalls gets all the calls that were made to MustEncodeJSON. Check the length with:
len(mockedServerEncoderDecoder.MustEncodeJSONCalls())