forked from TrueCloudLab/frostfs-node
[#496] node: Fix linter importas
Standardize the alias of the import frostfs-sdk-go/object as objectSDK. Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
4bbe9cc936
commit
033eaf77e1
80 changed files with 444 additions and 443 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session/test"
|
||||
|
@ -17,11 +17,11 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func blankValidObject(key *ecdsa.PrivateKey) *object.Object {
|
||||
func blankValidObject(key *ecdsa.PrivateKey) *objectSDK.Object {
|
||||
var idOwner user.ID
|
||||
user.IDFromKey(&idOwner, key.PublicKey)
|
||||
|
||||
obj := object.New()
|
||||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetOwnerID(&idOwner)
|
||||
|
||||
|
@ -66,20 +66,20 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("nil identifier", func(t *testing.T) {
|
||||
obj := object.New()
|
||||
obj := objectSDK.New()
|
||||
|
||||
require.ErrorIs(t, v.Validate(context.Background(), obj, false), errNilID)
|
||||
})
|
||||
|
||||
t.Run("nil container identifier", func(t *testing.T) {
|
||||
obj := object.New()
|
||||
obj := objectSDK.New()
|
||||
obj.SetID(oidtest.ID())
|
||||
|
||||
require.ErrorIs(t, v.Validate(context.Background(), obj, true), errNilCID)
|
||||
})
|
||||
|
||||
t.Run("unsigned object", func(t *testing.T) {
|
||||
obj := object.New()
|
||||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetID(oidtest.ID())
|
||||
|
||||
|
@ -94,12 +94,12 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
err := tok.Sign(ownerKey.PrivateKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
obj := object.New()
|
||||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&idOwner)
|
||||
|
||||
require.NoError(t, object.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
|
||||
require.NoError(t, v.Validate(context.Background(), obj, false))
|
||||
})
|
||||
|
@ -107,20 +107,20 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
t.Run("correct w/o session token", func(t *testing.T) {
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
require.NoError(t, object.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
|
||||
require.NoError(t, v.Validate(context.Background(), obj, false))
|
||||
})
|
||||
|
||||
t.Run("tombstone content", func(t *testing.T) {
|
||||
obj := object.New()
|
||||
obj.SetType(object.TypeTombstone)
|
||||
obj := objectSDK.New()
|
||||
obj.SetType(objectSDK.TypeTombstone)
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
|
||||
_, err := v.ValidateContent(obj)
|
||||
require.Error(t, err) // no tombstone content
|
||||
|
||||
content := object.NewTombstone()
|
||||
content := objectSDK.NewTombstone()
|
||||
content.SetMembers([]oid.ID{oidtest.ID()})
|
||||
|
||||
data, err := content.Marshal()
|
||||
|
@ -141,7 +141,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
_, err = v.ValidateContent(obj)
|
||||
require.Error(t, err) // no expiration epoch in tombstone
|
||||
|
||||
var expirationAttribute object.Attribute
|
||||
var expirationAttribute objectSDK.Attribute
|
||||
expirationAttribute.SetKey(objectV2.SysAttributeExpEpoch)
|
||||
expirationAttribute.SetValue(strconv.Itoa(10))
|
||||
|
||||
|
@ -163,20 +163,20 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
require.NoError(t, err) // all good
|
||||
|
||||
require.EqualValues(t, []oid.ID{id}, contentGot.Objects())
|
||||
require.Equal(t, object.TypeTombstone, contentGot.Type())
|
||||
require.Equal(t, objectSDK.TypeTombstone, contentGot.Type())
|
||||
})
|
||||
|
||||
t.Run("expiration", func(t *testing.T) {
|
||||
fn := func(val string) *object.Object {
|
||||
fn := func(val string) *objectSDK.Object {
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
var a object.Attribute
|
||||
var a objectSDK.Attribute
|
||||
a.SetKey(objectV2.SysAttributeExpEpoch)
|
||||
a.SetValue(val)
|
||||
|
||||
obj.SetAttributes(a)
|
||||
|
||||
require.NoError(t, object.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
|
||||
return obj
|
||||
}
|
||||
|
@ -221,11 +221,11 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
t.Run("duplication", func(t *testing.T) {
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
var a1 object.Attribute
|
||||
var a1 objectSDK.Attribute
|
||||
a1.SetKey("key1")
|
||||
a1.SetValue("val1")
|
||||
|
||||
var a2 object.Attribute
|
||||
var a2 objectSDK.Attribute
|
||||
a2.SetKey("key2")
|
||||
a2.SetValue("val2")
|
||||
|
||||
|
@ -244,7 +244,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
t.Run("empty value", func(t *testing.T) {
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
var a object.Attribute
|
||||
var a objectSDK.Attribute
|
||||
a.SetKey("key")
|
||||
|
||||
obj.SetAttributes(a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue