package redisutils import ( "errors" "github.com/stretchr/testify/assert" "testing" "time" ) var ErrFailedFunc = errors.New("some error") // GetCachedSetMock funcs. func SuccessGetCachedSetMock(t *testing.T, expKey string, response map[string]struct{}) func(key string) (map[string]struct{}, error) { return func(key string) (map[string]struct{}, error) { assert.Equal(t, expKey, key) return response, nil } } func NoKeyGetCachedSetMock(key string) (map[string]struct{}, error) { return nil, ErrCacheDoesntExist } func FailedGetCachedSetMock(key string) (map[string]struct{}, error) { return nil, ErrFailedFunc } // UpdateSetCacheMock funcs. func SuccessUpdateSetCacheMock(t *testing.T, expKey string, expCacheValues []interface{}) func(key string, cacheValues []interface{}) error { return func(key string, cacheValues []interface{}) error { assert.Equal(t, expKey, key) assert.Equal(t, expCacheValues, cacheValues) return nil } } func FailUpdateSetCacheMock(key string, cacheValues []interface{}) error { return ErrFailedFunc } // CreateSetCacheMock funcs. func SuccessCreateSetCacheMock(t *testing.T, expKey string, expCacheValues []interface{}, expExpireTime time.Time) func(key string, cacheValues []interface{}, expireTime time.Time) error { return func(key string, cacheValues []interface{}, expireTime time.Time) error { assert.Equal(t, expKey, key) assert.Equal(t, expCacheValues, cacheValues) assert.Equal(t, expExpireTime, expireTime) return nil } } func FailCreateSetCacheMock(key string, cacheValues []interface{}, expireTime time.Time) error { return ErrFailedFunc }