MCPcopy Create free account
hub / github.com/evcc-io/evcc / TestCacheReset

Function TestCacheReset

util/cache_test.go:57–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestCacheReset(t *testing.T) {
58 var i int64
59 g := func() (int64, error) {
60 i++
61 return i, nil
62 }
63
64 c := ResettableCached(g, 10*time.Minute)
65 clock := clock.NewMock()
66 c.clock = clock
67
68 test := func(exp int64) {
69 v, _ := c.Get()
70 if exp != v {
71 t.Errorf("expected %d, got %d", exp, v)
72 }
73 }
74
75 test(1)
76 test(1)
77 c.Reset()
78 test(2)
79 test(2)
80 clock.Add(10*time.Minute + 1)
81 test(3)
82}
83
84func TestRetryWithBackoff(t *testing.T) {
85 tests := []struct {

Callers

nothing calls this directly

Calls 6

ResettableCachedFunction · 0.85
GetMethod · 0.65
ResetMethod · 0.65
AddMethod · 0.65
testFunction · 0.50
ErrorfMethod · 0.45

Tested by

no test coverage detected