mirror of
https://github.com/pikami/cosmium.git
synced 2025-04-08 19:01:52 +01:00
Simplify constant initialization in unit tests
This commit is contained in:
parent
8e3db3e44d
commit
69b76c1c3e
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
"github.com/pikami/cosmium/parsers/nosql"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
// For Parser Debugging
|
||||
@ -102,20 +103,8 @@ func Test_Parse(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "456",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_String("456"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func Test_Execute_StringFunctions(t *testing.T) {
|
||||
@ -23,20 +24,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -61,13 +50,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
nil,
|
||||
},
|
||||
},
|
||||
@ -93,13 +76,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "pk"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
@ -128,20 +105,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -166,20 +131,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -204,20 +157,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -242,20 +183,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "2",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("2"),
|
||||
testutils.SelectItem_Constant_Int(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -352,13 +281,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 5,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(5),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -431,20 +354,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "old",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "new",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("old"),
|
||||
testutils.SelectItem_Constant_String("new"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -469,13 +380,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 3,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(3),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -524,13 +429,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 3,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(3),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -579,20 +478,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 5,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(1),
|
||||
testutils.SelectItem_Constant_Int(5),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func Test_Parse_Were(t *testing.T) {
|
||||
@ -22,10 +23,7 @@ func Test_Parse_Were(t *testing.T) {
|
||||
Filters: parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "isCool"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: true},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
)
|
||||
@ -51,18 +49,12 @@ func Test_Parse_Were(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "12345"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("12345"),
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "pk"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeInteger, Value: 123},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Int(123),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -87,10 +79,7 @@ func Test_Parse_Were(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "isCool"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: true},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
parsers.LogicalExpression{
|
||||
Operation: parsers.LogicalExpressionTypeOr,
|
||||
@ -98,18 +87,12 @@ func Test_Parse_Were(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "123"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("123"),
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "456"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("456"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -135,43 +118,28 @@ func Test_Parse_Were(t *testing.T) {
|
||||
Filters: parsers.LogicalExpression{
|
||||
Expressions: []interface{}{
|
||||
parsers.ComparisonExpression{
|
||||
Left: parsers.SelectItem{Path: []string{"c", "boolean"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: true},
|
||||
},
|
||||
Left: parsers.SelectItem{Path: []string{"c", "boolean"}},
|
||||
Right: testutils.SelectItem_Constant_Bool(true),
|
||||
Operation: "=",
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Left: parsers.SelectItem{Path: []string{"c", "integer"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeInteger, Value: 1},
|
||||
},
|
||||
Left: parsers.SelectItem{Path: []string{"c", "integer"}},
|
||||
Right: testutils.SelectItem_Constant_Int(1),
|
||||
Operation: "=",
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Left: parsers.SelectItem{Path: []string{"c", "float"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeFloat, Value: 6.9},
|
||||
},
|
||||
Left: parsers.SelectItem{Path: []string{"c", "float"}},
|
||||
Right: testutils.SelectItem_Constant_Float(6.9),
|
||||
Operation: "=",
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Left: parsers.SelectItem{Path: []string{"c", "string"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "hello"},
|
||||
},
|
||||
Left: parsers.SelectItem{Path: []string{"c", "string"}},
|
||||
Right: testutils.SelectItem_Constant_String("hello"),
|
||||
Operation: "=",
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Left: parsers.SelectItem{Path: []string{"c", "param"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeParameterConstant, Value: "@param_id1"},
|
||||
},
|
||||
Left: parsers.SelectItem{Path: []string{"c", "param"}},
|
||||
Right: testutils.SelectItem_Constant_Parameter("@param_id1"),
|
||||
Operation: "=",
|
||||
},
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
memoryexecutor "github.com/pikami/cosmium/query_executors/memory_executor"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func testQueryExecute(
|
||||
@ -111,20 +112,8 @@ func Test_Execute(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "123",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "456",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("123"),
|
||||
testutils.SelectItem_Constant_String("456"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
memoryexecutor "github.com/pikami/cosmium/query_executors/memory_executor"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func Test_Execute_StringFunctions(t *testing.T) {
|
||||
@ -33,20 +34,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "pk"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "aaa",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("aaa"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -81,13 +70,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "pk"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "aaa",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("aaa"),
|
||||
nil,
|
||||
},
|
||||
},
|
||||
@ -119,20 +102,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: " ",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: 123,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String(" "),
|
||||
testutils.SelectItem_Constant_Int(123),
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "pk"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
@ -171,20 +142,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "2",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("2"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -219,20 +178,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "3",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("3"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -267,20 +214,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "1",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeBoolean,
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("1"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -315,20 +250,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "o",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 4,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("o"),
|
||||
testutils.SelectItem_Constant_Int(4),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -397,13 +320,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 3,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(3),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -506,20 +423,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "world",
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeString,
|
||||
Value: "universe",
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_String("world"),
|
||||
testutils.SelectItem_Constant_String("universe"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -554,13 +459,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 3,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(3),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -629,13 +528,7 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 3,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(3),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -704,20 +597,8 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
Path: []string{"c", "str"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 2,
|
||||
},
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{
|
||||
Type: parsers.ConstantTypeInteger,
|
||||
Value: 4,
|
||||
},
|
||||
},
|
||||
testutils.SelectItem_Constant_Int(2),
|
||||
testutils.SelectItem_Constant_Int(4),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
memoryexecutor "github.com/pikami/cosmium/query_executors/memory_executor"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func Test_Execute_Where(t *testing.T) {
|
||||
@ -26,10 +27,7 @@ func Test_Execute_Where(t *testing.T) {
|
||||
Filters: parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "isCool"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: true},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
mockData,
|
||||
@ -52,10 +50,7 @@ func Test_Execute_Where(t *testing.T) {
|
||||
Filters: parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeParameterConstant, Value: "@param_id"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Parameter("@param_id"),
|
||||
},
|
||||
Parameters: map[string]interface{}{
|
||||
"@param_id": "456",
|
||||
@ -83,18 +78,12 @@ func Test_Execute_Where(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "67890"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("67890"),
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "pk"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeInteger, Value: 456},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Int(456),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -120,10 +109,7 @@ func Test_Execute_Where(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "isCool"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: true},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
parsers.LogicalExpression{
|
||||
Operation: parsers.LogicalExpressionTypeOr,
|
||||
@ -131,18 +117,12 @@ func Test_Execute_Where(t *testing.T) {
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "123"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("123"),
|
||||
},
|
||||
parsers.ComparisonExpression{
|
||||
Operation: "=",
|
||||
Left: parsers.SelectItem{Path: []string{"c", "id"}},
|
||||
Right: parsers.SelectItem{
|
||||
Type: parsers.SelectItemTypeConstant,
|
||||
Value: parsers.Constant{Type: parsers.ConstantTypeString, Value: "456"},
|
||||
},
|
||||
Right: testutils.SelectItem_Constant_String("456"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user