[#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:
parent
fc4f7429d5
commit
48837bd5da
1 changed files with 7 additions and 4 deletions
|
@ -88,13 +88,16 @@ func (t *Table) ToV2() *v2acl.Table {
|
|||
v2.SetContainerID(t.cid.ToV2())
|
||||
}
|
||||
|
||||
records := make([]*v2acl.Record, 0, len(t.records))
|
||||
for _, record := range t.records {
|
||||
records = append(records, record.ToV2())
|
||||
if t.records != nil {
|
||||
records := make([]*v2acl.Record, 0, len(t.records))
|
||||
for _, record := range t.records {
|
||||
records = append(records, record.ToV2())
|
||||
}
|
||||
|
||||
v2.SetRecords(records)
|
||||
}
|
||||
|
||||
v2.SetVersion(t.version.ToV2())
|
||||
v2.SetRecords(records)
|
||||
|
||||
return v2
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue