[#288] pkg/eacl: Document default values set in NewTable

Document field values of instance constructed via `NewTable`. Assert the
values in corresponding unit test.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-27 14:48:20 +03:00 committed by Leonard Lyubich
parent 8abf78009a
commit fc4f7429d5
2 changed files with 25 additions and 0 deletions

View file

@ -100,6 +100,13 @@ func (t *Table) ToV2() *v2acl.Table {
}
// NewTable creates, initializes and returns blank Table instance.
//
// Defaults:
// - version: pkg.SDKVersion();
// - container ID: nil;
// - records: nil;
// - session token: nil;
// - signature: nil.
func NewTable() *Table {
t := new(Table)
t.SetVersion(*pkg.SDKVersion())

View file

@ -119,4 +119,22 @@ func TestTable_ToV2(t *testing.T) {
require.Nil(t, x.ToV2())
})
t.Run("default values", func(t *testing.T) {
table := eacl.NewTable()
// check initial values
require.Equal(t, *pkg.SDKVersion(), table.Version())
require.Nil(t, table.Records())
require.Nil(t, table.CID())
require.Nil(t, table.SessionToken())
require.Nil(t, table.Signature())
// convert to v2 message
tableV2 := table.ToV2()
require.Equal(t, pkg.SDKVersion().ToV2(), tableV2.GetVersion())
require.Nil(t, tableV2.GetRecords())
require.Nil(t, tableV2.GetContainerID())
})
}