From 8031baddb6b65181a51e5aea04712fbc27defad4 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Tue, 9 Aug 2022 02:32:33 +0400 Subject: [PATCH] [#577] Fix cache tests Signed-off-by: Angira Kekteeva --- api/cache/cache_test.go | 21 ++++++++++++++++----- api/cache/objects_test.go | 22 ++++++++++++++++------ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/api/cache/cache_test.go b/api/cache/cache_test.go index 679b491b4..3d46ad792 100644 --- a/api/cache/cache_test.go +++ b/api/cache/cache_test.go @@ -71,15 +71,26 @@ func TestObjectCacheType(t *testing.T) { cache := New(DefaultObjectsConfig(logger)) addr := oidtest.Address() - objInfo := &data.ObjectInfo{ - ID: addr.Object(), - CID: addr.Container(), + + extObjInfo := &data.ExtendedObjectInfo{ + ObjectInfo: &data.ObjectInfo{ + ID: addr.Object(), + 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) val := cache.GetObject(addr) - require.Equal(t, objInfo, val) + require.Equal(t, extObjInfo, val) require.Equal(t, 0, observedLog.Len()) err = cache.cache.Set(addr, "tmp") diff --git a/api/cache/objects_test.go b/api/cache/objects_test.go index ab53617d0..9e63a2c3a 100644 --- a/api/cache/objects_test.go +++ b/api/cache/objects_test.go @@ -28,23 +28,33 @@ func TestCache(t *testing.T) { addr.SetContainer(cnrID) addr.SetObject(objID) - objInfo := &data.ObjectInfo{ - ID: addr.Object(), - CID: addr.Container(), + extObjInfo := &data.ExtendedObjectInfo{ + ObjectInfo: &data.ObjectInfo{ + ID: addr.Object(), + 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) { cache := New(getTestConfig()) - err := cache.PutObject(objInfo) + err := cache.PutObject(extObjInfo) require.NoError(t, err) actual := cache.GetObject(addr) - require.Equal(t, objInfo, actual) + require.Equal(t, extObjInfo, actual) }) t.Run("check delete", func(t *testing.T) { cache := New(getTestConfig()) - err := cache.PutObject(objInfo) + err := cache.PutObject(extObjInfo) require.NoError(t, err) cache.Delete(addr)