mock

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCtxWithMockLogger

func AppendCtxWithMockLogger(t *testing.T, ctx sdk.Context) (sdk.Context, *sdktestsmocks.MockLogger)
AppendCtxWithMockLogger sets the logger for an input context as a mock logger

with 'EXPECT' statements. This enables testing on functions logged to the context. For example,

```go // This is a passing test example import (

gomock "github.com/golang/mock/gomock"
sdktestsmocks "github.com/cosmos/cosmos-sdk/tests/mocks"

)

// assume t is a *testing.T variable.
ctx, logger := AppendCtxWithMockLogger(t, ctx)
logger.EXPECT().Debug("debug")
logger.EXPECT().Info("info")
logger.EXPECT().Error("error")

ctx.Logger().Debug("debug")
ctx.Logger().Info("info")
ctx.Logger().Error("error")

```

Types

This section is empty.

Jump to

Keyboard shortcuts

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