Documentation
¶
Index ¶
- type Fake
- func (f *Fake) AssertCalled(t *testing.T, op Op, key string, times int)
- func (f *Fake) AssertNotCalled(t *testing.T, op Op, key string)
- func (f *Fake) AssertTotal(t *testing.T, op Op, times int)
- func (f *Fake) Cache() *cache.Cache
- func (f *Fake) Count(op Op, key string) int
- func (f *Fake) Reset()
- func (f *Fake) Total(op Op) int
- type Op
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake exposes a deterministic in-memory store plus assertion helpers for tests. It wraps the memory store so no external services are needed.
func New ¶
func New() *Fake
New creates a Fake using an in-memory store. @group Testing Helpers Example:
f := cachefake.New()
c := f.Cache()
_ = c.SetString("settings:mode", "dark", 0)
func (*Fake) AssertCalled ¶
AssertCalled verifies key was touched by op the expected number of times. @group Testing Helpers Example:
f := cachefake.New()
c := f.Cache()
_ = c.SetString("settings:mode", "dark", 0)
t := &testing.T{}
f.AssertCalled(t, cachefake.OpSet, "settings:mode", 1)
func (*Fake) AssertNotCalled ¶
AssertNotCalled ensures key was never touched by op. @group Testing Helpers Example:
f := cachefake.New()
t := &testing.T{}
f.AssertNotCalled(t, cachefake.OpDelete, "settings:mode")
func (*Fake) AssertTotal ¶
AssertTotal ensures the total call count for an op matches times. @group Testing Helpers Example:
f := cachefake.New()
c := f.Cache()
_ = c.Delete("a")
_ = c.Delete("b")
t := &testing.T{}
f.AssertTotal(t, cachefake.OpDelete, 2)
func (*Fake) Cache ¶
Cache returns the cache facade to inject into code under test. @group Testing Helpers Example:
f := cachefake.New()
c := f.Cache()
_, _, _ = c.GetBytes("settings:mode")
func (*Fake) Count ¶
Count returns calls for op+key. @group Testing Helpers Example:
f := cachefake.New()
c := f.Cache()
_ = c.SetString("settings:mode", "dark", 0)
n := f.Count(cachefake.OpSet, "settings:mode")
_ = n