[#253] Caches refactoring

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2021-09-10 09:56:56 +03:00 committed by Kirillov Denis
parent 951eb6fda8
commit 19b917e3b5
30 changed files with 365 additions and 322 deletions

View file

@ -9,10 +9,12 @@ import (
"github.com/stretchr/testify/require"
)
const (
cachesize = 10
lifetime = time.Second * 5
)
func getTestConfig() *Config {
return &Config{
Size: 10,
Lifetime: 5 * time.Second,
}
}
func TestCache(t *testing.T) {
obj := objecttest.Object()
@ -21,7 +23,7 @@ func TestCache(t *testing.T) {
address.SetObjectID(obj.ID())
t.Run("check get", func(t *testing.T) {
cache := New(cachesize, lifetime)
cache := New(getTestConfig())
err := cache.Put(*obj)
require.NoError(t, err)
@ -30,7 +32,7 @@ func TestCache(t *testing.T) {
})
t.Run("check delete", func(t *testing.T) {
cache := New(cachesize, lifetime)
cache := New(getTestConfig())
err := cache.Put(*obj)
require.NoError(t, err)