mocks

package
v1.19.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 3 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 {
	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(baseCdc codec.Codec) *MockCodec

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

func (*MockCodec) MarshalJSON

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

func (*MockCodec) MustMarshalJSON

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

func (*MockCodec) MustUnmarshalJSON

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

func (*MockCodec) UnmarshalJSON

func (c *MockCodec) UnmarshalJSON(bz []byte, ptr proto.Message) 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