forked from TrueCloudLab/frostfs-s3-gw
parent
245e64900d
commit
8031baddb6
2 changed files with 32 additions and 11 deletions
17
api/cache/cache_test.go
vendored
17
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{
|
|
||||||
|
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")
|
||||||
|
|
18
api/cache/objects_test.go
vendored
18
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{
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue