diff --git a/pkg/policy/encode.go b/pkg/policy/encode.go index a7d3ef08..e003445d 100644 --- a/pkg/policy/encode.go +++ b/pkg/policy/encode.go @@ -8,6 +8,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/netmap" ) +// Encode parses data of PlacementPolicy to a string. func Encode(p *netmap.PlacementPolicy) []string { if p == nil { return nil diff --git a/pkg/policy/json.go b/pkg/policy/json.go index a0b474fd..3169bdbd 100644 --- a/pkg/policy/json.go +++ b/pkg/policy/json.go @@ -54,7 +54,7 @@ func ToJSON(np *netmap.PlacementPolicy) ([]byte, error) { return json.Marshal(p) } -// ToJSON creates placement policy from JSON. +// FromJSON creates placement policy from JSON. func FromJSON(data []byte) (*netmap.PlacementPolicy, error) { p := new(placement) if err := json.Unmarshal(data, p); err != nil { diff --git a/pkg/policy/query.go b/pkg/policy/query.go index 49042790..1b6447ef 100644 --- a/pkg/policy/query.go +++ b/pkg/policy/query.go @@ -9,10 +9,15 @@ import ( ) var ( - ErrInvalidNumber = errors.New("policy: expected positive integer") - ErrUnknownClause = errors.New("policy: unknown clause") - ErrUnknownOp = errors.New("policy: unknown operation") - ErrUnknownFilter = errors.New("policy: filter not found") + // ErrInvalidNumber is returned when a value of SELECT is 0. + ErrInvalidNumber = errors.New("policy: expected positive integer") + // ErrUnknownClause is returned when a statement(clause) in a query is unknown. + ErrUnknownClause = errors.New("policy: unknown clause") + // ErrUnknownOp is returned when an operation in a query is unknown. + ErrUnknownOp = errors.New("policy: unknown operation") + // ErrUnknownFilter is returned when a value of FROM in a query is unknown. + ErrUnknownFilter = errors.New("policy: filter not found") + // ErrUnknownSelector is returned when a value of IN is unknown. ErrUnknownSelector = errors.New("policy: selector not found") ) diff --git a/pkg/policy/query_test.go b/pkg/policy/query_test.go index b7c4cc76..ebe2be29 100644 --- a/pkg/policy/query_test.go +++ b/pkg/policy/query_test.go @@ -62,7 +62,6 @@ func TestFromSelectNoAttribute(t *testing.T) { r, err := Parse(q) require.NoError(t, err) require.EqualValues(t, expected, r) - }) t.Run("with filter", func(t *testing.T) { @@ -232,7 +231,6 @@ func TestValidation(t *testing.T) { _, err := Parse(q) require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err) }) - } func TestFilterStringSymbols(t *testing.T) {