storetest

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

	// DeleteValueFunc mocks the DeleteValue method.
	DeleteValueFunc func(ctx context.Context, key string) error

	// GetKeyValuePairsFunc mocks the GetKeyValuePairs method.
	GetKeyValuePairsFunc func(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error)

	// GetKeysFunc mocks the GetKeys method.
	GetKeysFunc func(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error)

	// GetSetMemberCountFunc mocks the GetSetMemberCount method.
	GetSetMemberCountFunc func(ctx context.Context, setKey string) (int64, error)

	// GetSetMemberValuesFunc mocks the GetSetMemberValues method.
	GetSetMemberValuesFunc func(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error)

	// GetTotalKeysFunc mocks the GetTotalKeys method.
	GetTotalKeysFunc func(ctx context.Context) (int64, error)

	// GetValueFunc mocks the GetValue method.
	GetValueFunc func(ctx context.Context, key string) (string, error)

	// SetAddFunc mocks the SetAdd method.
	SetAddFunc func(ctx context.Context, key string, members ...interface{}) error

	// SetRemFunc mocks the SetRem method.
	SetRemFunc func(ctx context.Context, key string, members ...interface{}) error

	// SetValueFunc mocks the SetValue method.
	SetValueFunc func(ctx context.Context, key string, value interface{}, expiration time.Duration) error

	// TransactionFunc mocks the Transaction method.
	TransactionFunc func(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, 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")
		},
		DeleteValueFunc: func(ctx context.Context, key string) error {
			panic("mock out the DeleteValue method")
		},
		GetKeyValuePairsFunc: func(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error) {
			panic("mock out the GetKeyValuePairs method")
		},
		GetKeysFunc: func(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error) {
			panic("mock out the GetKeys method")
		},
		GetSetMemberCountFunc: func(ctx context.Context, setKey string) (int64, error) {
			panic("mock out the GetSetMemberCount method")
		},
		GetSetMemberValuesFunc: func(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error) {
			panic("mock out the GetSetMemberValues method")
		},
		GetTotalKeysFunc: func(ctx context.Context) (int64, error) {
			panic("mock out the GetTotalKeys method")
		},
		GetValueFunc: func(ctx context.Context, key string) (string, error) {
			panic("mock out the GetValue method")
		},
		SetAddFunc: func(ctx context.Context, key string, members ...interface{}) error {
			panic("mock out the SetAdd method")
		},
		SetRemFunc: func(ctx context.Context, key string, members ...interface{}) error {
			panic("mock out the SetRem method")
		},
		SetValueFunc: func(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
			panic("mock out the SetValue method")
		},
		TransactionFunc: func(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, error) {
			panic("mock out the Transaction 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) DeleteValue added in v0.3.3

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

DeleteValue calls DeleteValueFunc.

func (*RedisMock) DeleteValueCalls added in v0.3.3

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

DeleteValueCalls gets all the calls that were made to DeleteValue. Check the length with:

len(mockedRedis.DeleteValueCalls())

func (*RedisMock) GetKeyValuePairs added in v0.3.5

func (mock *RedisMock) GetKeyValuePairs(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error)

GetKeyValuePairs calls GetKeyValuePairsFunc.

func (*RedisMock) GetKeyValuePairsCalls added in v0.3.5

func (mock *RedisMock) GetKeyValuePairsCalls() []struct {
	Ctx          context.Context
	MatchPattern string
	Count        int64
	Cursor       uint64
}

GetKeyValuePairsCalls gets all the calls that were made to GetKeyValuePairs. Check the length with:

len(mockedRedis.GetKeyValuePairsCalls())

func (*RedisMock) GetKeys added in v1.4.0

func (mock *RedisMock) GetKeys(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error)

GetKeys calls GetKeysFunc.

func (*RedisMock) GetKeysCalls added in v1.4.0

func (mock *RedisMock) GetKeysCalls() []struct {
	Ctx          context.Context
	MatchPattern string
	Count        int64
	Cursor       uint64
}

GetKeysCalls gets all the calls that were made to GetKeys. Check the length with:

len(mockedRedis.GetKeysCalls())

func (*RedisMock) GetSetMemberCount added in v1.4.0

func (mock *RedisMock) GetSetMemberCount(ctx context.Context, setKey string) (int64, error)

GetSetMemberCount calls GetSetMemberCountFunc.

func (*RedisMock) GetSetMemberCountCalls added in v1.4.0

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

GetSetMemberCountCalls gets all the calls that were made to GetSetMemberCount. Check the length with:

len(mockedRedis.GetSetMemberCountCalls())

func (*RedisMock) GetSetMemberValues added in v1.4.0

func (mock *RedisMock) GetSetMemberValues(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error)

GetSetMemberValues calls GetSetMemberValuesFunc.

func (*RedisMock) GetSetMemberValuesCalls added in v1.4.0

func (mock *RedisMock) GetSetMemberValuesCalls() []struct {
	Ctx          context.Context
	SetKey       string
	MatchPattern string
	ValuePrefix  string
	Count        int64
	Cursor       uint64
}

GetSetMemberValuesCalls gets all the calls that were made to GetSetMemberValues. Check the length with:

len(mockedRedis.GetSetMemberValuesCalls())

func (*RedisMock) GetTotalKeys added in v0.3.5

func (mock *RedisMock) GetTotalKeys(ctx context.Context) (int64, error)

GetTotalKeys calls GetTotalKeysFunc.

func (*RedisMock) GetTotalKeysCalls added in v0.3.5

func (mock *RedisMock) GetTotalKeysCalls() []struct {
	Ctx context.Context
}

GetTotalKeysCalls gets all the calls that were made to GetTotalKeys. Check the length with:

len(mockedRedis.GetTotalKeysCalls())

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())

func (*RedisMock) SetAdd added in v1.5.0

func (mock *RedisMock) SetAdd(ctx context.Context, key string, members ...interface{}) error

SetAdd calls SetAddFunc.

func (*RedisMock) SetAddCalls added in v1.5.0

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

SetAddCalls gets all the calls that were made to SetAdd. Check the length with:

len(mockedRedis.SetAddCalls())

func (*RedisMock) SetRem added in v1.5.0

func (mock *RedisMock) SetRem(ctx context.Context, key string, members ...interface{}) error

SetRem calls SetRemFunc.

func (*RedisMock) SetRemCalls added in v1.5.0

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

SetRemCalls gets all the calls that were made to SetRem. Check the length with:

len(mockedRedis.SetRemCalls())

func (*RedisMock) SetValue added in v0.3.2

func (mock *RedisMock) SetValue(ctx context.Context, key string, value interface{}, expiration time.Duration) error

SetValue calls SetValueFunc.

func (*RedisMock) SetValueCalls added in v0.3.2

func (mock *RedisMock) SetValueCalls() []struct {
	Ctx        context.Context
	Key        string
	Value      interface{}
	Expiration time.Duration
}

SetValueCalls gets all the calls that were made to SetValue. Check the length with:

len(mockedRedis.SetValueCalls())

func (*RedisMock) Transaction added in v1.4.0

func (mock *RedisMock) Transaction(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, error)

Transaction calls TransactionFunc.

func (*RedisMock) TransactionCalls added in v1.4.0

func (mock *RedisMock) TransactionCalls() []struct {
	Ctx   context.Context
	Queue func(redis.Pipeliner)
}

TransactionCalls gets all the calls that were made to Transaction. Check the length with:

len(mockedRedis.TransactionCalls())

type StorerMock

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

	// DeleteValueFunc mocks the DeleteValue method.
	DeleteValueFunc func(ctx context.Context, key string) error

	// GetKeyValuePairsFunc mocks the GetKeyValuePairs method.
	GetKeyValuePairsFunc func(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error)

	// GetKeysFunc mocks the GetKeys method.
	GetKeysFunc func(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error)

	// GetSetMemberCountFunc mocks the GetSetMemberCount method.
	GetSetMemberCountFunc func(ctx context.Context, setKey string) (int64, error)

	// GetSetMemberValuesFunc mocks the GetSetMemberValues method.
	GetSetMemberValuesFunc func(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error)

	// GetTotalKeysFunc mocks the GetTotalKeys method.
	GetTotalKeysFunc func(ctx context.Context) (int64, error)

	// GetValueFunc mocks the GetValue method.
	GetValueFunc func(ctx context.Context, key string) (string, error)

	// SetAddFunc mocks the SetAdd method.
	SetAddFunc func(ctx context.Context, key string, members ...interface{}) error

	// SetRemFunc mocks the SetRem method.
	SetRemFunc func(ctx context.Context, key string, members ...interface{}) error

	// SetValueFunc mocks the SetValue method.
	SetValueFunc func(ctx context.Context, key string, value interface{}, expiration time.Duration) error

	// TransactionFunc mocks the Transaction method.
	TransactionFunc func(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, 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")
		},
		DeleteValueFunc: func(ctx context.Context, key string) error {
			panic("mock out the DeleteValue method")
		},
		GetKeyValuePairsFunc: func(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error) {
			panic("mock out the GetKeyValuePairs method")
		},
		GetKeysFunc: func(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error) {
			panic("mock out the GetKeys method")
		},
		GetSetMemberCountFunc: func(ctx context.Context, setKey string) (int64, error) {
			panic("mock out the GetSetMemberCount method")
		},
		GetSetMemberValuesFunc: func(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error) {
			panic("mock out the GetSetMemberValues method")
		},
		GetTotalKeysFunc: func(ctx context.Context) (int64, error) {
			panic("mock out the GetTotalKeys method")
		},
		GetValueFunc: func(ctx context.Context, key string) (string, error) {
			panic("mock out the GetValue method")
		},
		SetAddFunc: func(ctx context.Context, key string, members ...interface{}) error {
			panic("mock out the SetAdd method")
		},
		SetRemFunc: func(ctx context.Context, key string, members ...interface{}) error {
			panic("mock out the SetRem method")
		},
		SetValueFunc: func(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
			panic("mock out the SetValue method")
		},
		TransactionFunc: func(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, error) {
			panic("mock out the Transaction 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) DeleteValue added in v0.3.3

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

DeleteValue calls DeleteValueFunc.

func (*StorerMock) DeleteValueCalls added in v0.3.3

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

DeleteValueCalls gets all the calls that were made to DeleteValue. Check the length with:

len(mockedStorer.DeleteValueCalls())

func (*StorerMock) GetKeyValuePairs added in v0.3.5

func (mock *StorerMock) GetKeyValuePairs(ctx context.Context, matchPattern string, count int64, cursor uint64) (map[string]string, uint64, error)

GetKeyValuePairs calls GetKeyValuePairsFunc.

func (*StorerMock) GetKeyValuePairsCalls added in v0.3.5

func (mock *StorerMock) GetKeyValuePairsCalls() []struct {
	Ctx          context.Context
	MatchPattern string
	Count        int64
	Cursor       uint64
}

GetKeyValuePairsCalls gets all the calls that were made to GetKeyValuePairs. Check the length with:

len(mockedStorer.GetKeyValuePairsCalls())

func (*StorerMock) GetKeys added in v1.4.0

func (mock *StorerMock) GetKeys(ctx context.Context, matchPattern string, count int64, cursor uint64) ([]string, uint64, error)

GetKeys calls GetKeysFunc.

func (*StorerMock) GetKeysCalls added in v1.4.0

func (mock *StorerMock) GetKeysCalls() []struct {
	Ctx          context.Context
	MatchPattern string
	Count        int64
	Cursor       uint64
}

GetKeysCalls gets all the calls that were made to GetKeys. Check the length with:

len(mockedStorer.GetKeysCalls())

func (*StorerMock) GetSetMemberCount added in v1.4.0

func (mock *StorerMock) GetSetMemberCount(ctx context.Context, setKey string) (int64, error)

GetSetMemberCount calls GetSetMemberCountFunc.

func (*StorerMock) GetSetMemberCountCalls added in v1.4.0

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

GetSetMemberCountCalls gets all the calls that were made to GetSetMemberCount. Check the length with:

len(mockedStorer.GetSetMemberCountCalls())

func (*StorerMock) GetSetMemberValues added in v1.4.0

func (mock *StorerMock) GetSetMemberValues(ctx context.Context, setKey string, matchPattern string, valuePrefix string, count int64, cursor uint64) (map[string]string, uint64, error)

GetSetMemberValues calls GetSetMemberValuesFunc.

func (*StorerMock) GetSetMemberValuesCalls added in v1.4.0

func (mock *StorerMock) GetSetMemberValuesCalls() []struct {
	Ctx          context.Context
	SetKey       string
	MatchPattern string
	ValuePrefix  string
	Count        int64
	Cursor       uint64
}

GetSetMemberValuesCalls gets all the calls that were made to GetSetMemberValues. Check the length with:

len(mockedStorer.GetSetMemberValuesCalls())

func (*StorerMock) GetTotalKeys added in v0.3.5

func (mock *StorerMock) GetTotalKeys(ctx context.Context) (int64, error)

GetTotalKeys calls GetTotalKeysFunc.

func (*StorerMock) GetTotalKeysCalls added in v0.3.5

func (mock *StorerMock) GetTotalKeysCalls() []struct {
	Ctx context.Context
}

GetTotalKeysCalls gets all the calls that were made to GetTotalKeys. Check the length with:

len(mockedStorer.GetTotalKeysCalls())

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())

func (*StorerMock) SetAdd added in v1.5.0

func (mock *StorerMock) SetAdd(ctx context.Context, key string, members ...interface{}) error

SetAdd calls SetAddFunc.

func (*StorerMock) SetAddCalls added in v1.5.0

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

SetAddCalls gets all the calls that were made to SetAdd. Check the length with:

len(mockedStorer.SetAddCalls())

func (*StorerMock) SetRem added in v1.5.0

func (mock *StorerMock) SetRem(ctx context.Context, key string, members ...interface{}) error

SetRem calls SetRemFunc.

func (*StorerMock) SetRemCalls added in v1.5.0

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

SetRemCalls gets all the calls that were made to SetRem. Check the length with:

len(mockedStorer.SetRemCalls())

func (*StorerMock) SetValue added in v0.3.2

func (mock *StorerMock) SetValue(ctx context.Context, key string, value interface{}, expiration time.Duration) error

SetValue calls SetValueFunc.

func (*StorerMock) SetValueCalls added in v0.3.2

func (mock *StorerMock) SetValueCalls() []struct {
	Ctx        context.Context
	Key        string
	Value      interface{}
	Expiration time.Duration
}

SetValueCalls gets all the calls that were made to SetValue. Check the length with:

len(mockedStorer.SetValueCalls())

func (*StorerMock) Transaction added in v1.4.0

func (mock *StorerMock) Transaction(ctx context.Context, queue func(redis.Pipeliner)) ([]redis.Cmder, error)

Transaction calls TransactionFunc.

func (*StorerMock) TransactionCalls added in v1.4.0

func (mock *StorerMock) TransactionCalls() []struct {
	Ctx   context.Context
	Queue func(redis.Pipeliner)
}

TransactionCalls gets all the calls that were made to Transaction. Check the length with:

len(mockedStorer.TransactionCalls())

Jump to

Keyboard shortcuts

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