mocks

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockCodec

type MockCodec struct {
	Base              codec.Codec
	MarshalJSONErrs   []string
	UnmarshalJSONErrs []string
}

MockCodec is a wrapper on a codec that allows injection of errors on these functions: MarshalJSON, MustMarshalJSON, UnmarshalJSON, MustUnmarshalJSON.

func NewMockCodec

func NewMockCodec() *MockCodec

NewMockCodec creates a new mock codec based on the standard test encoding config codec.

func (*MockCodec) Marshal

func (c *MockCodec) Marshal(o codec.ProtoMarshaler) ([]byte, error)

func (*MockCodec) MarshalInterface

func (c *MockCodec) MarshalInterface(i proto.Message) ([]byte, error)

func (*MockCodec) MarshalInterfaceJSON

func (c *MockCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error)

func (*MockCodec) MarshalJSON

func (c *MockCodec) MarshalJSON(o proto.Message) ([]byte, error)

func (*MockCodec) MarshalLengthPrefixed

func (c *MockCodec) MarshalLengthPrefixed(o codec.ProtoMarshaler) ([]byte, error)

func (*MockCodec) MustMarshal

func (c *MockCodec) MustMarshal(o codec.ProtoMarshaler) []byte

func (*MockCodec) MustMarshalJSON

func (c *MockCodec) MustMarshalJSON(o proto.Message) []byte

func (*MockCodec) MustMarshalLengthPrefixed

func (c *MockCodec) MustMarshalLengthPrefixed(o codec.ProtoMarshaler) []byte

func (*MockCodec) MustUnmarshal

func (c *MockCodec) MustUnmarshal(bz []byte, ptr codec.ProtoMarshaler)

func (*MockCodec) MustUnmarshalJSON

func (c *MockCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)

func (*MockCodec) MustUnmarshalLengthPrefixed

func (c *MockCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler)

func (*MockCodec) Unmarshal

func (c *MockCodec) Unmarshal(bz []byte, ptr codec.ProtoMarshaler) error

func (*MockCodec) UnmarshalInterface

func (c *MockCodec) UnmarshalInterface(bz []byte, ptr interface{}) error

func (*MockCodec) UnmarshalInterfaceJSON

func (c *MockCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error

func (*MockCodec) UnmarshalJSON

func (c *MockCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error

func (*MockCodec) UnmarshalLengthPrefixed

func (c *MockCodec) UnmarshalLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler) error

func (*MockCodec) UnpackAny

func (c *MockCodec) UnpackAny(a *codectypes.Any, iface interface{}) error

func (*MockCodec) WithMarshalJSONErrs

func (c *MockCodec) WithMarshalJSONErrs(errMsgs ...string) *MockCodec

WithMarshalJSONErrs adds the given errors to be returned from MarshalJSON or MustMarshalJSON. Each entry is used once in the order they are provided. An empty string indicates no error (do the normal thing). The receiver is both updated and returned.

func (*MockCodec) WithUnmarshalJSONErrs

func (c *MockCodec) WithUnmarshalJSONErrs(errMsgs ...string) *MockCodec

WithUnmarshalJSONErrs adds the given errors to be returned from UnmarshalJSON or MustUnmarshalJSON. Each entry is used once in the order they are provided. An empty string indicates no error (do the normal thing). The receiver is both updated and returned.

Jump to

Keyboard shortcuts

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