[#577] Fix cache tests

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-08-09 02:32:33 +04:00 committed by Kira
parent 245e64900d
commit 8031baddb6
2 changed files with 32 additions and 11 deletions

View file

@ -71,15 +71,26 @@ func TestObjectCacheType(t *testing.T) {
cache := New(DefaultObjectsConfig(logger)) cache := New(DefaultObjectsConfig(logger))
addr := oidtest.Address() addr := oidtest.Address()
objInfo := &data.ObjectInfo{
extObjInfo := &data.ExtendedObjectInfo{
ObjectInfo: &data.ObjectInfo{
ID: addr.Object(), ID: addr.Object(),
CID: addr.Container(), CID: addr.Container(),
},
NodeVersion: &data.NodeVersion{
BaseNodeVersion: data.BaseNodeVersion{
FilePath: "obj",
Size: 50,
},
IsUnversioned: true,
},
IsLatest: true,
} }
err := cache.PutObject(objInfo) err := cache.PutObject(extObjInfo)
require.NoError(t, err) require.NoError(t, err)
val := cache.GetObject(addr) val := cache.GetObject(addr)
require.Equal(t, objInfo, val) require.Equal(t, extObjInfo, val)
require.Equal(t, 0, observedLog.Len()) require.Equal(t, 0, observedLog.Len())
err = cache.cache.Set(addr, "tmp") err = cache.cache.Set(addr, "tmp")

View file

@ -28,23 +28,33 @@ func TestCache(t *testing.T) {
addr.SetContainer(cnrID) addr.SetContainer(cnrID)
addr.SetObject(objID) addr.SetObject(objID)
objInfo := &data.ObjectInfo{ extObjInfo := &data.ExtendedObjectInfo{
ObjectInfo: &data.ObjectInfo{
ID: addr.Object(), ID: addr.Object(),
CID: addr.Container(), CID: addr.Container(),
},
NodeVersion: &data.NodeVersion{
BaseNodeVersion: data.BaseNodeVersion{
FilePath: "obj",
Size: 50,
},
IsUnversioned: true,
},
IsLatest: true,
} }
t.Run("check get", func(t *testing.T) { t.Run("check get", func(t *testing.T) {
cache := New(getTestConfig()) cache := New(getTestConfig())
err := cache.PutObject(objInfo) err := cache.PutObject(extObjInfo)
require.NoError(t, err) require.NoError(t, err)
actual := cache.GetObject(addr) actual := cache.GetObject(addr)
require.Equal(t, objInfo, actual) require.Equal(t, extObjInfo, actual)
}) })
t.Run("check delete", func(t *testing.T) { t.Run("check delete", func(t *testing.T) {
cache := New(getTestConfig()) cache := New(getTestConfig())
err := cache.PutObject(objInfo) err := cache.PutObject(extObjInfo)
require.NoError(t, err) require.NoError(t, err)
cache.Delete(addr) cache.Delete(addr)