[#488] Change cache key types
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
e104855633
commit
206a7aa395
5 changed files with 24 additions and 27 deletions
26
api/cache/objectslist_test.go
vendored
26
api/cache/objectslist_test.go
vendored
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -24,9 +24,9 @@ func getTestObjectsListConfig() *Config {
|
|||
|
||||
func TestObjectsListCache(t *testing.T) {
|
||||
var (
|
||||
listSize = 10
|
||||
ids []oid.ID
|
||||
userKey = "key"
|
||||
listSize = 10
|
||||
ids []oid.ID
|
||||
cidKey, cidKey2 = cidtest.ID(), cidtest.ID()
|
||||
)
|
||||
|
||||
for i := 0; i < listSize; i++ {
|
||||
|
@ -37,7 +37,7 @@ func TestObjectsListCache(t *testing.T) {
|
|||
var (
|
||||
config = getTestObjectsListConfig()
|
||||
cache = NewObjectsListCache(config)
|
||||
cacheKey = ObjectsListKey{cid: userKey}
|
||||
cacheKey = ObjectsListKey{cid: cidKey}
|
||||
)
|
||||
|
||||
err := cache.Put(cacheKey, ids)
|
||||
|
@ -54,7 +54,7 @@ func TestObjectsListCache(t *testing.T) {
|
|||
t.Run("get cache with empty prefix", func(t *testing.T) {
|
||||
var (
|
||||
cache = NewObjectsListCache(getTestObjectsListConfig())
|
||||
cacheKey = ObjectsListKey{cid: userKey}
|
||||
cacheKey = ObjectsListKey{cid: cidKey}
|
||||
)
|
||||
err := cache.Put(cacheKey, ids)
|
||||
require.NoError(t, err)
|
||||
|
@ -69,7 +69,7 @@ func TestObjectsListCache(t *testing.T) {
|
|||
|
||||
t.Run("get cache with prefix", func(t *testing.T) {
|
||||
cacheKey := ObjectsListKey{
|
||||
cid: userKey,
|
||||
cid: cidKey,
|
||||
prefix: "dir",
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,12 @@ func TestObjectsListCache(t *testing.T) {
|
|||
t.Run("get cache with other prefix", func(t *testing.T) {
|
||||
var (
|
||||
cacheKey = ObjectsListKey{
|
||||
cid: userKey,
|
||||
cid: cidKey,
|
||||
prefix: "dir",
|
||||
}
|
||||
|
||||
newKey = ObjectsListKey{
|
||||
cid: "key",
|
||||
cid: cidKey,
|
||||
prefix: "obj",
|
||||
}
|
||||
)
|
||||
|
@ -109,10 +109,10 @@ func TestObjectsListCache(t *testing.T) {
|
|||
t.Run("get cache with non-existing key", func(t *testing.T) {
|
||||
var (
|
||||
cacheKey = ObjectsListKey{
|
||||
cid: userKey,
|
||||
cid: cidKey,
|
||||
}
|
||||
newKey = ObjectsListKey{
|
||||
cid: "asdf",
|
||||
cid: cidKey2,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -127,13 +127,13 @@ func TestObjectsListCache(t *testing.T) {
|
|||
|
||||
func TestCleanCacheEntriesChangedWithPutObject(t *testing.T) {
|
||||
var (
|
||||
id cid.ID
|
||||
id = cidtest.ID()
|
||||
oids = []oid.ID{oidtest.ID()}
|
||||
keys []ObjectsListKey
|
||||
)
|
||||
|
||||
for _, p := range []string{"", "dir/", "dir/lol/"} {
|
||||
keys = append(keys, ObjectsListKey{cid: id.EncodeToString(), prefix: p})
|
||||
keys = append(keys, ObjectsListKey{cid: id, prefix: p})
|
||||
}
|
||||
|
||||
t.Run("put object to the root of the bucket", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue