forked from TrueCloudLab/frostfs-s3-gw
parent
245e64900d
commit
8031baddb6
2 changed files with 32 additions and 11 deletions
21
api/cache/cache_test.go
vendored
21
api/cache/cache_test.go
vendored
|
@ -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{
|
|
||||||
ID: addr.Object(),
|
extObjInfo := &data.ExtendedObjectInfo{
|
||||||
CID: addr.Container(),
|
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)
|
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")
|
||||||
|
|
22
api/cache/objects_test.go
vendored
22
api/cache/objects_test.go
vendored
|
@ -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{
|
||||||
ID: addr.Object(),
|
ObjectInfo: &data.ObjectInfo{
|
||||||
CID: addr.Container(),
|
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) {
|
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)
|
||||||
|
|
Loading…
Reference in a new issue