commit 5480365fa9f178f1adc2d887f4e545ed8eba6c0a from: Sergey Bronnikov date: Tue Oct 08 14:33:40 2024 UTC test: replace testcase by luatest's testcases The tests `array.test.lua` and `map.test.lua` require the remote Tarantool instance for running testcases. When tests are executed by test-run.py, it runs this Tarantool instance. The testcases that require the remote instance were ported to luatest to make tests able to run with ctest. The testcases `builtins-13.1` and `builtins-14.1` are companion testcases and were moved as well. Required by patches for CTest support, because allows to execute aforementioned tests without test-run.py. NO_CHANGELOG=codehealth NO_DOC=codehealth NO_TEST=codehealth (cherry picked from commit 47295fdebc1910b990c391c26fe92918a9c0c001) commit - a3c2f8bc54cb398faacf94ca8c99f089ebcb55a8 commit + 5480365fa9f178f1adc2d887f4e545ed8eba6c0a blob - /dev/null blob + bbb566de662ce8bbac7810e8dc5939c6a1ffa9f9 (mode 644) --- /dev/null +++ test/sql-luatest/array_test.lua @@ -0,0 +1,30 @@ +local server = require('luatest.server') +local t = require('luatest') + +local g = t.group() + +g.before_all(function() + g.server = server:new({alias = 'array'}) + g.server:start() +end) + +g.after_all(function() + g.server:stop() +end) + +-- Make sure that ARRAY values can be used as bound variable. +g.test_array_binding_local = function() + g.server:exec(function() + local sql = [[SELECT #a;]] + local arg = {{['#a'] = {1, 2, 3}}} + t.assert_equals(box.execute(sql, arg).rows[1][1], {1, 2, 3}) + end) +end + +g.test_array_binding_remote = function() + local conn = g.server.net_box + local ok, res = pcall(conn.execute, conn, [[SELECT #a;]], + {{['#a'] = {1, 2, 3}}}) + t.assert_equals(ok, true) + t.assert_equals(res.rows[1][1], {1, 2, 3}) +end blob - bb1e2ebcd739ec5c675181d4b4484bb34da6f9b3 blob + b93c4b7536e7f645ecb3165f146aaa31524bb634 --- test/sql-luatest/map_test.lua +++ test/sql-luatest/map_test.lua @@ -318,5 +318,23 @@ g.test_map_9 = function() local sql = [[SELECT {'a' : 1, 'a' : 2, 'b' : 3, 'a' : 4};]] local res = {{{b = 3, a = 4}}} t.assert_equals(box.execute(sql).rows, res) + end) +end + +-- Make sure that MAP values can be used as a bound variable. +g.test_map_binding_local = function() + g.server:exec(function() + local sql = [[SELECT #a;]] + local arg = {{['#a'] = {abc = 2, [1] = 3}}} + local res = {abc = 2, [1] = 3} + t.assert_equals(box.execute(sql, arg).rows[1][1], res) end) end + +g.test_map_binding_remote = function() + local conn = g.server.net_box + local ok, res = pcall(conn.execute, conn, [[SELECT #a;]], + {{['#a'] = {abc = 2, [1] = 3}}}) + t.assert_equals(ok, true) + t.assert_equals(res.rows[1][1], {abc = 2, [1] = 3}) +end blob - d40e70184d5e3e083f0efb4d0524c8a8e12557dc blob + 01c08c2d390438a19ba6b9c3ce86774380785178 --- test/sql-tap/array.test.lua +++ test/sql-tap/array.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool local test = require("sqltester") -test:plan(117) +test:plan(115) box.schema.func.create('A1', { language = 'Lua', @@ -1021,31 +1021,8 @@ test:do_execsql_test( SELECT typeof([1]); ]], { "array" - }) - --- Make sure that ARRAY values can be used as bound variable. -test:do_test( - "builtins-14.1", - function() - local res = box.execute([[SELECT #a;]], {{['#a'] = {1, 2, 3}}}) - return {res.rows[1][1]} - end, { - {1, 2, 3} }) -local remote = require('net.box') -box.cfg{listen = os.getenv('LISTEN')} -local cn = remote.connect(box.cfg.listen) -test:do_test( - "builtins-14.2", - function() - local res = cn:execute([[SELECT #a;]], {{['#a'] = {1, 2, 3}}}) - return {res.rows[1][1]} - end, { - {1, 2, 3} - }) -cn:close() - box.execute([[DROP TABLE t1;]]) box.execute([[DROP TABLE t;]]) blob - 3606ea3ddd23951adc85a9c33d23c4d4057c5cfd blob + 17d3d52062e4fd491eecd79e8278adaea01654be --- test/sql-tap/map.test.lua +++ test/sql-tap/map.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool local test = require("sqltester") -test:plan(112) +test:plan(110) box.schema.func.create('M1', { language = 'Lua', @@ -979,31 +979,8 @@ test:do_catchsql_test( SELECT ZEROBLOB(m) FROM t; ]], { 1, "Failed to execute SQL statement: wrong arguments for function ZEROBLOB()" - }) - --- Make sure that MAP values can be used as a bound variable. -test:do_test( - "builtins-13.1", - function() - local res = box.execute([[SELECT #a;]], {{['#a'] = {abc = 2, [1] = 3}}}) - return {res.rows[1][1]} - end, { - {abc = 2, [1] = 3} }) -local remote = require('net.box') -box.cfg{listen = os.getenv('LISTEN')} -local cn = remote.connect(box.cfg.listen) -test:do_test( - "builtins-13.2", - function() - local res = cn:execute([[SELECT #a;]], {{['#a'] = {abc = 2, [1] = 3}}}) - return {res.rows[1][1]} - end, { - {abc = 2, [1] = 3} - }) -cn:close() - box.execute([[DROP TABLE t1;]]) box.execute([[DROP TABLE t;]])