[#131] container: Set current SDK version in New
Make `container.New` function to write `version.Current` into created container. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2624347d9b
commit
eee9a72a4e
2 changed files with 5 additions and 3 deletions
|
@ -28,7 +28,7 @@ type Container struct {
|
||||||
// - token: nil;
|
// - token: nil;
|
||||||
// - sig: nil;
|
// - sig: nil;
|
||||||
// - basicACL: acl.PrivateBasicRule;
|
// - basicACL: acl.PrivateBasicRule;
|
||||||
// - version: nil;
|
// - version: version.Current;
|
||||||
// - nonce: random UUID;
|
// - nonce: random UUID;
|
||||||
// - attr: nil;
|
// - attr: nil;
|
||||||
// - policy: nil;
|
// - policy: nil;
|
||||||
|
@ -53,6 +53,7 @@ func New(opts ...Option) *Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
cnr.SetAttributes(cnrOptions.attributes)
|
cnr.SetAttributes(cnrOptions.attributes)
|
||||||
|
cnr.SetVersion(version.Current())
|
||||||
|
|
||||||
return cnr
|
return cnr
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
|
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
|
||||||
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
|
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
|
||||||
sigtest "github.com/nspcc-dev/neofs-sdk-go/signature/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"
|
versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -106,12 +107,12 @@ func TestContainer_ToV2(t *testing.T) {
|
||||||
// check initial values
|
// check initial values
|
||||||
require.Nil(t, cnt.SessionToken())
|
require.Nil(t, cnt.SessionToken())
|
||||||
require.Nil(t, cnt.Signature())
|
require.Nil(t, cnt.Signature())
|
||||||
require.Nil(t, cnt.Version())
|
|
||||||
require.Nil(t, cnt.Attributes())
|
require.Nil(t, cnt.Attributes())
|
||||||
require.Nil(t, cnt.PlacementPolicy())
|
require.Nil(t, cnt.PlacementPolicy())
|
||||||
require.Nil(t, cnt.OwnerID())
|
require.Nil(t, cnt.OwnerID())
|
||||||
|
|
||||||
require.EqualValues(t, acl.PrivateBasicRule, cnt.BasicACL())
|
require.EqualValues(t, acl.PrivateBasicRule, cnt.BasicACL())
|
||||||
|
require.Equal(t, version.Current(), cnt.Version())
|
||||||
|
|
||||||
nonce, err := cnt.NonceUUID()
|
nonce, err := cnt.NonceUUID()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -125,11 +126,11 @@ func TestContainer_ToV2(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, nonce.String(), nonceV2.String())
|
require.Equal(t, nonce.String(), nonceV2.String())
|
||||||
|
|
||||||
require.Nil(t, cntV2.GetVersion())
|
|
||||||
require.Nil(t, cntV2.GetAttributes())
|
require.Nil(t, cntV2.GetAttributes())
|
||||||
require.Nil(t, cntV2.GetPlacementPolicy())
|
require.Nil(t, cntV2.GetPlacementPolicy())
|
||||||
require.Nil(t, cntV2.GetOwnerID())
|
require.Nil(t, cntV2.GetOwnerID())
|
||||||
|
|
||||||
require.Equal(t, uint32(acl.PrivateBasicRule), cntV2.GetBasicACL())
|
require.Equal(t, uint32(acl.PrivateBasicRule), cntV2.GetBasicACL())
|
||||||
|
require.Equal(t, version.Current().ToV2(), cntV2.GetVersion())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue