mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-28 11:03:42 +02:00
cache: adding factory method for redis
This commit is contained in:
parent
2f31eb47d4
commit
d1d4bf58b1
2 changed files with 61 additions and 0 deletions
33
internal/cache/redis_store_test.go
vendored
33
internal/cache/redis_store_test.go
vendored
|
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-redis/redismock/v9"
|
||||
"github.com/karlseguin/typed"
|
||||
|
||||
redis_cache "github.com/go-redis/cache/v9"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -16,6 +17,38 @@ type testItem struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
func TestRedisStore_getOptionsDefaults(t *testing.T) {
|
||||
opts := typed.Typed{}
|
||||
|
||||
expected := options{
|
||||
Stats: false,
|
||||
Size: 1000,
|
||||
TTL: 10 * time.Minute,
|
||||
}
|
||||
|
||||
actual := getOptions(opts)
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestRedisStore_getOptions(t *testing.T) {
|
||||
opts := typed.Typed{
|
||||
"stats": true,
|
||||
"size": 123,
|
||||
"ttl": 60,
|
||||
}
|
||||
|
||||
expected := options{
|
||||
Stats: true,
|
||||
Size: 123,
|
||||
TTL: 60 * time.Minute,
|
||||
}
|
||||
|
||||
actual := getOptions(opts)
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestRedisStore_Set(t *testing.T) {
|
||||
client, mock := redismock.NewClientMock()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue