parent
295be71f00
commit
376642565f
1 changed files with 40 additions and 0 deletions
40
api/cache/object_cache_test.go
vendored
Normal file
40
api/cache/object_cache_test.go
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
objecttest "github.com/nspcc-dev/neofs-api-go/pkg/object/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
cachesize = 10
|
||||
lifetime = time.Second * 5
|
||||
)
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
var (
|
||||
address = objecttest.Address()
|
||||
object = objecttest.Object()
|
||||
)
|
||||
|
||||
t.Run("check get", func(t *testing.T) {
|
||||
cache := New(cachesize, lifetime)
|
||||
err := cache.Put(address, *object)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual := cache.Get(address)
|
||||
require.Equal(t, object, actual)
|
||||
})
|
||||
|
||||
t.Run("check delete", func(t *testing.T) {
|
||||
cache := New(cachesize, lifetime)
|
||||
err := cache.Put(address, *object)
|
||||
require.NoError(t, err)
|
||||
|
||||
cache.Delete(address)
|
||||
actual := cache.Get(address)
|
||||
require.Nil(t, actual)
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue