forked from TrueCloudLab/frostfs-api-go
[#288] pkg/eacl: Document default values set in NewRecord
Document field values of instance constructed via `NewRecord`. Assert the values in corresponding unit test. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
18a3c4d54f
commit
374c37983d
2 changed files with 24 additions and 0 deletions
|
@ -156,6 +156,12 @@ func (r *Record) ToV2() *v2acl.Record {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRecord creates and returns blank Record instance.
|
// NewRecord creates and returns blank Record instance.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - action: ActionUnknown;
|
||||||
|
// - operation: OperationUnknown;
|
||||||
|
// - targets: nil,
|
||||||
|
// - filters: nil.
|
||||||
func NewRecord() *Record {
|
func NewRecord() *Record {
|
||||||
return new(Record)
|
return new(Record)
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,4 +126,22 @@ func TestRecord_ToV2(t *testing.T) {
|
||||||
|
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
record := NewRecord()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Equal(t, OperationUnknown, record.Operation())
|
||||||
|
require.Equal(t, ActionUnknown, record.Action())
|
||||||
|
require.Nil(t, record.Targets())
|
||||||
|
require.Nil(t, record.Filters())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
recordV2 := record.ToV2()
|
||||||
|
|
||||||
|
require.Equal(t, v2acl.OperationUnknown, recordV2.GetOperation())
|
||||||
|
require.Equal(t, v2acl.ActionUnknown, recordV2.GetAction())
|
||||||
|
require.Nil(t, recordV2.GetTargets())
|
||||||
|
require.Nil(t, recordV2.GetFilters())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue