frostfs-sdk-go/netmap/policy_test.go

56 lines
1.2 KiB
Go
Raw Permalink Normal View History

package netmap_test
import (
"testing"
. "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
netmaptest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap/test"
"github.com/stretchr/testify/require"
)
func TestPlacementPolicyEncoding(t *testing.T) {
v := netmaptest.PlacementPolicy()
t.Run("binary", func(t *testing.T) {
var v2 PlacementPolicy
require.NoError(t, v2.Unmarshal(v.Marshal()))
require.Equal(t, v, v2)
})
t.Run("json", func(t *testing.T) {
data, err := v.MarshalJSON()
require.NoError(t, err)
var v2 PlacementPolicy
require.NoError(t, v2.UnmarshalJSON(data))
require.Equal(t, v, v2)
})
}
func TestDecodeSelectFilterExpr(t *testing.T) {
for _, s := range []string{
"SELECT 1 FROM *",
"FILTER Color EQ 'Red' AS RedNode",
`
FILTER Color EQ 'Red' AS RedNode
FILTER @RedNode AND Shape EQ 'Cirle' AS RedCircleNode
`,
`
SELECT 1 FROM RedCircleNode
FILTER Color EQ 'Red' AS RedNode
FILTER @RedNode AND Shape EQ 'Cirle' AS RedCircleNode
`,
`
CBF 1
SELECT 1 FROM RedCircleNode
FILTER Color EQ 'Red' AS RedNode
FILTER @RedNode AND Shape EQ 'Cirle' AS RedCircleNode
`,
} {
_, err := DecodeSelectFilterString(s)
require.NoError(t, err)
}
}