From 72adf5f972e3951cfd5b77a80c0e8380bda5cd51 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 8 Jun 2021 11:26:23 +0300 Subject: [PATCH] [#293] pkg/eacl: Implement and use generator of Table Signed-off-by: Leonard Lyubich --- pkg/acl/eacl/table_test.go | 6 ++---- pkg/acl/eacl/test/generate.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/acl/eacl/table_test.go b/pkg/acl/eacl/table_test.go index f3638ca6..06c7c7ab 100644 --- a/pkg/acl/eacl/table_test.go +++ b/pkg/acl/eacl/table_test.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" + eacltest "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test" "github.com/stretchr/testify/require" @@ -65,10 +66,7 @@ func TestTable_AddRecord(t *testing.T) { } func TestRecordEncoding(t *testing.T) { - tab := eacl.NewTable() - tab.AddRecord( - eacl.CreateRecord(eacl.ActionDeny, eacl.OperationHead), - ) + tab := eacltest.Table() t.Run("binary", func(t *testing.T) { data, err := tab.Marshal() diff --git a/pkg/acl/eacl/test/generate.go b/pkg/acl/eacl/test/generate.go index 1f5fcbd6..456871a2 100644 --- a/pkg/acl/eacl/test/generate.go +++ b/pkg/acl/eacl/test/generate.go @@ -4,6 +4,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" + sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test" ) // Target returns random eacl.Target. @@ -31,3 +32,14 @@ func Record() *eacl.Record { return x } + +func Table() *eacl.Table { + x := eacl.NewTable() + + x.SetCID(cidtest.Generate()) + x.SetSessionToken(sessiontest.Generate()) + x.AddRecord(Record()) + x.AddRecord(Record()) + + return x +}