[#288] pkg/eacl: Fix conversion of slices in Table.ToV2 method

Nil slice of records of the `Table` should be converted to nil slice in
corresponding field of API v2 message structure.

Add nil-check in `Table.ToV2` implementation. The changes fix corresponding
unit test.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-27 14:50:37 +03:00 committed by Leonard Lyubich
parent fc4f7429d5
commit 48837bd5da

View file

@ -88,13 +88,16 @@ func (t *Table) ToV2() *v2acl.Table {
v2.SetContainerID(t.cid.ToV2()) v2.SetContainerID(t.cid.ToV2())
} }
if t.records != nil {
records := make([]*v2acl.Record, 0, len(t.records)) records := make([]*v2acl.Record, 0, len(t.records))
for _, record := range t.records { for _, record := range t.records {
records = append(records, record.ToV2()) records = append(records, record.ToV2())
} }
v2.SetVersion(t.version.ToV2())
v2.SetRecords(records) v2.SetRecords(records)
}
v2.SetVersion(t.version.ToV2())
return v2 return v2
} }