Documentation
¶
Overview ¶
Package cachetest provides a mock implementation of gas.CacheProvider for use in tests. The mock records all calls and allows configuring per-method behavior via function fields.
mock := &cachetest.MockCache{}
mock.GetFn = func(ctx context.Context, key string) ([]byte, error) {
return []byte("value"), nil
}
Index ¶
- type Call
- type MockCache
- func (m *MockCache) CallCount(method string) int
- func (m *MockCache) CheckHealth(ctx context.Context) error
- func (m *MockCache) CheckReady(ctx context.Context) error
- func (m *MockCache) Delete(ctx context.Context, key string) error
- func (m *MockCache) Exists(ctx context.Context, key string) (bool, error)
- func (m *MockCache) Get(ctx context.Context, key string) ([]byte, error)
- func (m *MockCache) Reset()
- func (m *MockCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockCache ¶
type MockCache struct {
GetFn func(ctx context.Context, key string) ([]byte, error)
SetFn func(ctx context.Context, key string, value []byte, ttl time.Duration) error
DeleteFn func(ctx context.Context, key string) error
ExistsFn func(ctx context.Context, key string) (bool, error)
CheckHealthFn func(ctx context.Context) error
CheckReadyFn func(ctx context.Context) error
Calls []Call
// contains filtered or unexported fields
}
MockCache is a configurable mock of gas.CacheProvider. Each method delegates to its corresponding Fn field if set, otherwise returns the zero value. All calls are recorded in the Calls slice for assertions.
func (*MockCache) CheckHealth ¶
CheckHealth records the call and delegates to CheckHealthFn if set.
func (*MockCache) CheckReady ¶
CheckReady records the call and delegates to CheckReadyFn if set.
Click to show internal directories.
Click to hide internal directories.