github.com/cloudreve/Cloudreve/v3@v3.0.0-20240224133659-3edb00a6484c/pkg/mocks/cachemock/mock.go (about) 1 package cachemock 2 3 import "github.com/stretchr/testify/mock" 4 5 type CacheClientMock struct { 6 mock.Mock 7 } 8 9 func (c CacheClientMock) Set(key string, value interface{}, ttl int) error { 10 return c.Called(key, value, ttl).Error(0) 11 } 12 13 func (c CacheClientMock) Get(key string) (interface{}, bool) { 14 args := c.Called(key) 15 return args.Get(0), args.Bool(1) 16 } 17 18 func (c CacheClientMock) Gets(keys []string, prefix string) (map[string]interface{}, []string) { 19 args := c.Called(keys, prefix) 20 return args.Get(0).(map[string]interface{}), args.Get(1).([]string) 21 } 22 23 func (c CacheClientMock) Sets(values map[string]interface{}, prefix string) error { 24 return c.Called(values).Error(0) 25 } 26 27 func (c CacheClientMock) Delete(keys []string, prefix string) error { 28 return c.Called(keys, prefix).Error(0) 29 } 30 31 func (c CacheClientMock) Persist(path string) error { 32 return c.Called(path).Error(0) 33 } 34 35 func (c CacheClientMock) Restore(path string) error { 36 return c.Called(path).Error(0) 37 }