storetest

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 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 RedisMock

type RedisMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(contextMoqParam context.Context, checkState *healthcheck.CheckState) error

	// GetValueFunc mocks the GetValue method.
	GetValueFunc func(ctx context.Context, key string) (string, error)
	// contains filtered or unexported fields
}

RedisMock is a mock implementation of store.Redis.

func TestSomethingThatUsesRedis(t *testing.T) {

	// make and configure a mocked store.Redis
	mockedRedis := &RedisMock{
		CheckerFunc: func(contextMoqParam context.Context, checkState *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		GetValueFunc: func(ctx context.Context, key string) (string, error) {
			panic("mock out the GetValue method")
		},
	}

	// use mockedRedis in code that requires store.Redis
	// and then make assertions.

}

func (*RedisMock) Checker

func (mock *RedisMock) Checker(contextMoqParam context.Context, checkState *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*RedisMock) CheckerCalls

func (mock *RedisMock) CheckerCalls() []struct {
	ContextMoqParam context.Context
	CheckState      *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedRedis.CheckerCalls())

func (*RedisMock) GetValue

func (mock *RedisMock) GetValue(ctx context.Context, key string) (string, error)

GetValue calls GetValueFunc.

func (*RedisMock) GetValueCalls

func (mock *RedisMock) GetValueCalls() []struct {
	Ctx context.Context
	Key string
}

GetValueCalls gets all the calls that were made to GetValue. Check the length with:

len(mockedRedis.GetValueCalls())

type StorerMock

type StorerMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error

	// GetValueFunc mocks the GetValue method.
	GetValueFunc func(ctx context.Context, key string) (string, error)
	// contains filtered or unexported fields
}

StorerMock is a mock implementation of store.Storer.

func TestSomethingThatUsesStorer(t *testing.T) {

	// make and configure a mocked store.Storer
	mockedStorer := &StorerMock{
		CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		GetValueFunc: func(ctx context.Context, key string) (string, error) {
			panic("mock out the GetValue method")
		},
	}

	// use mockedStorer in code that requires store.Storer
	// and then make assertions.

}

func (*StorerMock) Checker

func (mock *StorerMock) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*StorerMock) CheckerCalls

func (mock *StorerMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedStorer.CheckerCalls())

func (*StorerMock) GetValue

func (mock *StorerMock) GetValue(ctx context.Context, key string) (string, error)

GetValue calls GetValueFunc.

func (*StorerMock) GetValueCalls

func (mock *StorerMock) GetValueCalls() []struct {
	Ctx context.Context
	Key string
}

GetValueCalls gets all the calls that were made to GetValue. Check the length with:

len(mockedStorer.GetValueCalls())

Jump to

Keyboard shortcuts

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