forked from TrueCloudLab/frostfs-sdk-go
[nspcc-dev/neofs-node#116] policy: Add comments
Added comments to exported variables and functions, fix typos in comments and extra newlines in code Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
3ef4b2c4cf
commit
0caf8cfd95
4 changed files with 11 additions and 7 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Encode parses data of PlacementPolicy to a string.
|
||||||
func Encode(p *netmap.PlacementPolicy) []string {
|
func Encode(p *netmap.PlacementPolicy) []string {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -54,7 +54,7 @@ func ToJSON(np *netmap.PlacementPolicy) ([]byte, error) {
|
||||||
return json.Marshal(p)
|
return json.Marshal(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON creates placement policy from JSON.
|
// FromJSON creates placement policy from JSON.
|
||||||
func FromJSON(data []byte) (*netmap.PlacementPolicy, error) {
|
func FromJSON(data []byte) (*netmap.PlacementPolicy, error) {
|
||||||
p := new(placement)
|
p := new(placement)
|
||||||
if err := json.Unmarshal(data, p); err != nil {
|
if err := json.Unmarshal(data, p); err != nil {
|
||||||
|
|
|
@ -9,10 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrInvalidNumber = errors.New("policy: expected positive integer")
|
// ErrInvalidNumber is returned when a value of SELECT is 0.
|
||||||
ErrUnknownClause = errors.New("policy: unknown clause")
|
ErrInvalidNumber = errors.New("policy: expected positive integer")
|
||||||
ErrUnknownOp = errors.New("policy: unknown operation")
|
// ErrUnknownClause is returned when a statement(clause) in a query is unknown.
|
||||||
ErrUnknownFilter = errors.New("policy: filter not found")
|
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")
|
ErrUnknownSelector = errors.New("policy: selector not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ func TestFromSelectNoAttribute(t *testing.T) {
|
||||||
r, err := Parse(q)
|
r, err := Parse(q)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, expected, r)
|
require.EqualValues(t, expected, r)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("with filter", func(t *testing.T) {
|
t.Run("with filter", func(t *testing.T) {
|
||||||
|
@ -232,7 +231,6 @@ func TestValidation(t *testing.T) {
|
||||||
_, err := Parse(q)
|
_, err := Parse(q)
|
||||||
require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err)
|
require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterStringSymbols(t *testing.T) {
|
func TestFilterStringSymbols(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue