forked from TrueCloudLab/frostfs-api-go
[#288] pkg/eacl: Convert nil eACL table to nil API v2 message
Make `Table.ToV2` method to return `nil` when called on `nil`. Write corresponding unit test. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
8c70b4714e
commit
8abf78009a
2 changed files with 14 additions and 0 deletions
|
@ -75,7 +75,13 @@ func (t *Table) SetSignature(sig *pkg.Signature) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToV2 converts Table to v2 acl.EACLTable message.
|
// ToV2 converts Table to v2 acl.EACLTable message.
|
||||||
|
//
|
||||||
|
// Nil Table converts to nil.
|
||||||
func (t *Table) ToV2() *v2acl.Table {
|
func (t *Table) ToV2() *v2acl.Table {
|
||||||
|
if t == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
v2 := new(v2acl.Table)
|
v2 := new(v2acl.Table)
|
||||||
|
|
||||||
if t.cid != nil {
|
if t.cid != nil {
|
||||||
|
|
|
@ -112,3 +112,11 @@ func TestTable_Signature(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, sig, table.Signature())
|
require.Equal(t, sig, table.Signature())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTable_ToV2(t *testing.T) {
|
||||||
|
t.Run("nil", func(t *testing.T) {
|
||||||
|
var x *eacl.Table
|
||||||
|
|
||||||
|
require.Nil(t, x.ToV2())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue