Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
59
pkg/redis/redisutils/cache_set_mock_funcs.go
Normal file
59
pkg/redis/redisutils/cache_set_mock_funcs.go
Normal file
@@ -0,0 +1,59 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user