forked from TrueCloudLab/frostfs-sdk-go
[nspcc-dev/neofs-node#116] policy: Move files from neofs-node repo
Took from commit on neofs-node: f81ecbe8db17e63674a47b4b6d49575aced3c16d Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
07c8150071
commit
0eeddf6dfe
9 changed files with 1076 additions and 0 deletions
36
pkg/policy/encode_test.go
Normal file
36
pkg/policy/encode_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package policy_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/policy"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEncode(t *testing.T) {
|
||||
testCases := []string{
|
||||
`REP 1 IN X
|
||||
CBF 1
|
||||
SELECT 2 IN SAME Location FROM * AS X`,
|
||||
|
||||
`REP 1
|
||||
SELECT 2 IN City FROM Good
|
||||
FILTER Country EQ RU AS FromRU
|
||||
FILTER @FromRU AND Rating GT 7 AS Good`,
|
||||
|
||||
`REP 7 IN SPB
|
||||
SELECT 1 IN City FROM SPBSSD AS SPB
|
||||
FILTER City EQ SPB AND SSD EQ true OR City EQ SPB AND Rating GE 5 AS SPBSSD`,
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
q, err := policy.Parse(testCase)
|
||||
require.NoError(t, err)
|
||||
|
||||
got := policy.Encode(q)
|
||||
fmt.Println(strings.Join(got, "\n"))
|
||||
require.Equal(t, testCase, strings.Join(got, "\n"))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue