forked from TrueCloudLab/frostfs-api-go
[#288] pkg/eacl: Document default values set in NewTarget
Document field values of instance constructed via `NewTarget`. Assert the values in corresponding unit test. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5844096017
commit
b81f39368e
2 changed files with 19 additions and 0 deletions
|
@ -124,6 +124,10 @@ func (t *Target) ToV2() *v2acl.Target {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTarget creates, initializes and returns blank Target instance.
|
// NewTarget creates, initializes and returns blank Target instance.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - role: RoleUnknown;
|
||||||
|
// - keys: nil.
|
||||||
func NewTarget() *Target {
|
func NewTarget() *Target {
|
||||||
return NewTargetFromV2(new(v2acl.Target))
|
return NewTargetFromV2(new(v2acl.Target))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
"github.com/nspcc-dev/neofs-crypto/test"
|
"github.com/nspcc-dev/neofs-crypto/test"
|
||||||
|
@ -68,4 +69,18 @@ func TestTarget_ToV2(t *testing.T) {
|
||||||
|
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
target := NewTarget()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Equal(t, RoleUnknown, target.Role())
|
||||||
|
require.Nil(t, target.BinaryKeys())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
targetV2 := target.ToV2()
|
||||||
|
|
||||||
|
require.Equal(t, acl.RoleUnknown, targetV2.GetRole())
|
||||||
|
require.Nil(t, targetV2.GetKeys())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue