From eee9a72a4eaaad3ba086303ca415cff7eb5558d9 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 9 Feb 2022 15:19:05 +0300 Subject: [PATCH] [#131] container: Set current SDK version in `New` Make `container.New` function to write `version.Current` into created container. Signed-off-by: Leonard Lyubich --- container/container.go | 3 ++- container/container_test.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/container/container.go b/container/container.go index 7449ce22..b9bff7b6 100644 --- a/container/container.go +++ b/container/container.go @@ -28,7 +28,7 @@ type Container struct { // - token: nil; // - sig: nil; // - basicACL: acl.PrivateBasicRule; -// - version: nil; +// - version: version.Current; // - nonce: random UUID; // - attr: nil; // - policy: nil; @@ -53,6 +53,7 @@ func New(opts ...Option) *Container { } cnr.SetAttributes(cnrOptions.attributes) + cnr.SetVersion(version.Current()) return cnr } diff --git a/container/container_test.go b/container/container_test.go index 2598cff6..ee87061b 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -11,6 +11,7 @@ import ( ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test" sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test" sigtest "github.com/nspcc-dev/neofs-sdk-go/signature/test" + "github.com/nspcc-dev/neofs-sdk-go/version" versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test" "github.com/stretchr/testify/require" ) @@ -106,12 +107,12 @@ func TestContainer_ToV2(t *testing.T) { // check initial values require.Nil(t, cnt.SessionToken()) require.Nil(t, cnt.Signature()) - require.Nil(t, cnt.Version()) require.Nil(t, cnt.Attributes()) require.Nil(t, cnt.PlacementPolicy()) require.Nil(t, cnt.OwnerID()) require.EqualValues(t, acl.PrivateBasicRule, cnt.BasicACL()) + require.Equal(t, version.Current(), cnt.Version()) nonce, err := cnt.NonceUUID() require.NoError(t, err) @@ -125,11 +126,11 @@ func TestContainer_ToV2(t *testing.T) { require.Equal(t, nonce.String(), nonceV2.String()) - require.Nil(t, cntV2.GetVersion()) require.Nil(t, cntV2.GetAttributes()) require.Nil(t, cntV2.GetPlacementPolicy()) require.Nil(t, cntV2.GetOwnerID()) require.Equal(t, uint32(acl.PrivateBasicRule), cntV2.GetBasicACL()) + require.Equal(t, version.Current().ToV2(), cntV2.GetVersion()) }) }