[#168] acl: Implement binary/JSON encoders/decoders on Table
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ae68790bbd
commit
233756ca8f
6 changed files with 117 additions and 96 deletions
|
@ -78,3 +78,30 @@ func TestTable_AddRecord(t *testing.T) {
|
|||
|
||||
require.Equal(t, records, table.Records())
|
||||
}
|
||||
|
||||
func TestRecordEncoding(t *testing.T) {
|
||||
tab := eacl.NewTable()
|
||||
tab.AddRecord(
|
||||
eacl.CreateRecord(eacl.ActionDeny, eacl.OperationHead),
|
||||
)
|
||||
|
||||
t.Run("binary", func(t *testing.T) {
|
||||
data, err := tab.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
tab2 := eacl.NewTable()
|
||||
require.NoError(t, tab2.Unmarshal(data))
|
||||
|
||||
require.Equal(t, tab, tab2)
|
||||
})
|
||||
|
||||
t.Run("json", func(t *testing.T) {
|
||||
data, err := tab.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
|
||||
r2 := eacl.NewTable()
|
||||
require.NoError(t, r2.UnmarshalJSON(data))
|
||||
|
||||
require.Equal(t, tab, r2)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue