mirror of https://github.com/tidwall/tile38.git
Tests and commands.json for WHEREEVAL.
This commit is contained in:
parent
29f4737e5d
commit
9ffca9aa10
|
@ -360,6 +360,22 @@
|
|||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVAL",
|
||||
"name": ["script","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVALSHA",
|
||||
"name": ["sha1","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "NOFIELDS",
|
||||
"name": [],
|
||||
|
@ -435,6 +451,22 @@
|
|||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVAL",
|
||||
"name": ["script","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVALSHA",
|
||||
"name": ["sha1","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "NOFIELDS",
|
||||
"name": [],
|
||||
|
@ -528,6 +560,22 @@
|
|||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVAL",
|
||||
"name": ["script","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVALSHA",
|
||||
"name": ["sha1","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "NOFIELDS",
|
||||
"name": [],
|
||||
|
@ -672,6 +720,22 @@
|
|||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVAL",
|
||||
"name": ["script","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVALSHA",
|
||||
"name": ["sha1","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "NOFIELDS",
|
||||
"name": [],
|
||||
|
@ -860,6 +924,22 @@
|
|||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVAL",
|
||||
"name": ["script","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "WHEREEVALSHA",
|
||||
"name": ["sha1","numargs","arg"],
|
||||
"type": ["string","integer","string"],
|
||||
"optional": true,
|
||||
"multiple": true,
|
||||
"variadic": true
|
||||
},
|
||||
{
|
||||
"command": "NOFIELDS",
|
||||
"name": [],
|
||||
|
|
|
@ -30,6 +30,7 @@ func subTestKeys(t *testing.T, mc *mockServer) {
|
|||
runStep(t, mc, "PDEL", keys_PDEL_test)
|
||||
runStep(t, mc, "FIELDS", keys_FIELDS_test)
|
||||
runStep(t, mc, "WHEREIN", keys_WHEREIN_test)
|
||||
runStep(t, mc, "WHEREEVAL", keys_WHEREEVAL_test)
|
||||
}
|
||||
|
||||
func keys_BOUNDS_test(mc *mockServer) error {
|
||||
|
@ -353,3 +354,16 @@ func keys_WHEREIN_test(mc *mockServer) error {
|
|||
{"WITHIN", "mykey", "WHEREIN", "a", 3, 0, 1, 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]] [myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]]]]`},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func keys_WHEREEVAL_test(mc *mockServer) error {
|
||||
return mc.DoBatch([][]interface{}{
|
||||
{"SET", "mykey", "myid_a1", "FIELD", "a", 1, "POINT", 33, -115}, {"OK"},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1])", 1, 0.5, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]]]]`},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1])", "a", 0.5, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {"ERR invalid argument 'a'"},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1])", 1, 0.5, 4, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {"ERR invalid argument '4'"},
|
||||
{"SET", "mykey", "myid_a2", "FIELD", "a", 2, "POINT", 32.99, -115}, {"OK"},
|
||||
{"SET", "mykey", "myid_a3", "FIELD", "a", 3, "POINT", 33, -115.02}, {"OK"},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1]) and FIELDS.a ~= tonumber(ARGV[2])", 2, 0.5, 3, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]] [myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]]]]`},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue