Skip to content

Commit

Permalink
[nspcc-dev/neofs-node#116] policy: Add comments to exported variables…
Browse files Browse the repository at this point in the history
…, fix typos

Signed-off-by: Angira Kekteeva <[email protected]>
  • Loading branch information
masterSplinter01 committed May 20, 2021
1 parent 71aa260 commit bb6dc71
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/policy/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
)

//Encode parses data of PlacementPolicy to a string.
func Encode(p *netmap.PlacementPolicy) []string {
if p == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/policy/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 9 additions & 4 deletions pkg/policy/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,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")
)

Expand Down
2 changes: 0 additions & 2 deletions pkg/policy/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func TestFromSelectNoAttribute(t *testing.T) {
r, err := Parse(q)
require.NoError(t, err)
require.Equal(t, expected, r)

})

t.Run("with filter", func(t *testing.T) {
Expand Down Expand Up @@ -232,7 +231,6 @@ func TestValidation(t *testing.T) {
_, err := Parse(q)
require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err)
})

}

func newFilter(name, key, value string, op netmap.Operation, sub ...*netmap.Filter) *netmap.Filter {
Expand Down

0 comments on commit bb6dc71

Please sign in to comment.