forked from TrueCloudLab/frostfs-api-go
[#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:
parent
8abf78009a
commit
fc4f7429d5
2 changed files with 25 additions and 0 deletions
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue