diff --git a/api/cache/cache_test.go b/api/cache/cache_test.go index 388b53d5..4e97535f 100644 --- a/api/cache/cache_test.go +++ b/api/cache/cache_test.go @@ -6,7 +6,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" - "github.com/nspcc-dev/neofs-sdk-go/object" 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" @@ -72,19 +71,20 @@ func TestObjectCacheType(t *testing.T) { cache := New(DefaultObjectsConfig(logger)) addr := oidtest.Address() - obj := object.New() - obj.SetContainerID(addr.Container()) - obj.SetID(addr.Object()) + objInfo := &data.ObjectInfo{ + ID: addr.Object(), + CID: addr.Container(), + } - err := cache.Put(*obj) + err := cache.PutObject(objInfo) require.NoError(t, err) - val := cache.Get(addr) - require.Equal(t, obj, val) + val := cache.GetObject(addr) + require.Equal(t, objInfo, val) require.Equal(t, 0, observedLog.Len()) err = cache.cache.Set(addr.EncodeToString(), "tmp") require.NoError(t, err) - assertInvalidCacheEntry(t, cache.Get(addr), observedLog) + assertInvalidCacheEntry(t, cache.GetObject(addr), observedLog) } func TestObjectsListCacheType(t *testing.T) { diff --git a/api/cache/objects_test.go b/api/cache/objects_test.go index 2cbf1271..ab53617d 100644 --- a/api/cache/objects_test.go +++ b/api/cache/objects_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/nspcc-dev/neofs-s3-gw/api/data" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/stretchr/testify/require" @@ -27,22 +28,27 @@ func TestCache(t *testing.T) { addr.SetContainer(cnrID) addr.SetObject(objID) + objInfo := &data.ObjectInfo{ + ID: addr.Object(), + CID: addr.Container(), + } + t.Run("check get", func(t *testing.T) { cache := New(getTestConfig()) - err := cache.Put(*obj) + err := cache.PutObject(objInfo) require.NoError(t, err) - actual := cache.Get(addr) - require.Equal(t, obj, actual) + actual := cache.GetObject(addr) + require.Equal(t, objInfo, actual) }) t.Run("check delete", func(t *testing.T) { cache := New(getTestConfig()) - err := cache.Put(*obj) + err := cache.PutObject(objInfo) require.NoError(t, err) cache.Delete(addr) - actual := cache.Get(addr) + actual := cache.GetObject(addr) require.Nil(t, actual) }) } diff --git a/api/handler/head_test.go b/api/handler/head_test.go index f6beb272..ff6f3e73 100644 --- a/api/handler/head_test.go +++ b/api/handler/head_test.go @@ -20,7 +20,7 @@ func TestConditionalHead(t *testing.T) { require.NoError(t, err) objName := "object" - createTestObject(ctx, t, tc, bktInfo, objName) + objInfo := createTestObject(ctx, t, tc, bktInfo, objName) w, r := prepareTestRequest(t, bktName, objName, nil) tc.Handler().HeadObjectHandler(w, r) @@ -41,7 +41,8 @@ func TestConditionalHead(t *testing.T) { assertStatus(t, w, http.StatusPreconditionFailed) w, r = prepareTestRequest(t, bktName, objName, nil) - r.Header.Set(api.IfUnmodifiedSince, time.Now().UTC().Format(http.TimeFormat)) + unmodifiedSince := objInfo.Created.Add(time.Minute) + r.Header.Set(api.IfUnmodifiedSince, unmodifiedSince.Format(http.TimeFormat)) tc.Handler().HeadObjectHandler(w, r) assertStatus(t, w, http.StatusOK)