Skip to content

Commit 89e3760

Browse files
test: replace tostring(error) with error.message in SQL TAP tests
Follows-up previous commit in scope of SQL TAP harness. Needed for tarantool#9105 NO_CHANGELOG=<tests change> NO_DOC=<tests change>
1 parent b88c7a0 commit 89e3760

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

test/sql-tap/built-in-functions.test.lua

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test:do_test(
133133
"builtins-2.2",
134134
function()
135135
local res = {pcall(box.execute, [[SELECT CHAR_LENGTH(?);]], {1})}
136-
return {tostring(res[3])}
136+
return {res[3].message}
137137
end, {
138138
"Type mismatch: can not convert integer(1) to string"
139139
})
@@ -153,7 +153,7 @@ test:do_test(
153153
"builtins-2.4",
154154
function()
155155
local res = {pcall(box.execute, [[SELECT CHARACTER_LENGTH(?);]], {1})}
156-
return {tostring(res[3])}
156+
return {res[3].message}
157157
end, {
158158
"Type mismatch: can not convert integer(1) to string"
159159
})
@@ -173,7 +173,7 @@ test:do_test(
173173
"builtins-2.6",
174174
function()
175175
local res = {pcall(box.execute, [[SELECT CHAR(?);]], {'1'})}
176-
return {tostring(res[3])}
176+
return {res[3].message}
177177
end, {
178178
"Type mismatch: can not convert string('1') to integer"
179179
})
@@ -193,7 +193,7 @@ test:do_test(
193193
"builtins-2.8",
194194
function()
195195
local res = {pcall(box.execute, [[SELECT HEX(?);]], {1})}
196-
return {tostring(res[3])}
196+
return {res[3].message}
197197
end, {
198198
"Type mismatch: can not convert integer(1) to varbinary"
199199
})
@@ -213,7 +213,7 @@ test:do_test(
213213
"builtins-2.10",
214214
function()
215215
local res = {pcall(box.execute, [[SELECT LENGTH(?);]], {1})}
216-
return {tostring(res[3])}
216+
return {res[3].message}
217217
end, {
218218
"Type mismatch: can not convert integer(1) to string"
219219
})
@@ -233,7 +233,7 @@ test:do_test(
233233
"builtins-2.12",
234234
function()
235235
local res = {pcall(box.execute, [[SELECT ? LIKE '%';]], {1})}
236-
return {tostring(res[3])}
236+
return {res[3].message}
237237
end, {
238238
"Type mismatch: can not convert integer(1) to string"
239239
})
@@ -253,7 +253,7 @@ test:do_test(
253253
"builtins-2.14",
254254
function()
255255
local res = {pcall(box.execute, [[SELECT LOWER(?);]], {1})}
256-
return {tostring(res[3])}
256+
return {res[3].message}
257257
end, {
258258
"Type mismatch: can not convert integer(1) to string"
259259
})
@@ -273,7 +273,7 @@ test:do_test(
273273
"builtins-2.16",
274274
function()
275275
local res = {pcall(box.execute, [[SELECT UPPER(?);]], {1})}
276-
return {tostring(res[3])}
276+
return {res[3].message}
277277
end, {
278278
"Type mismatch: can not convert integer(1) to string"
279279
})
@@ -293,7 +293,7 @@ test:do_test(
293293
"builtins-2.18",
294294
function()
295295
local res = {pcall(box.execute, [[SELECT POSITION(?, ?);]], {1, 1})}
296-
return {tostring(res[3])}
296+
return {res[3].message}
297297
end, {
298298
"Type mismatch: can not convert integer(1) to string"
299299
})
@@ -313,7 +313,7 @@ test:do_test(
313313
"builtins-2.20",
314314
function()
315315
local res = {pcall(box.execute, [[SELECT RANDOMBLOB(?);]], {'1'})}
316-
return {tostring(res[3])}
316+
return {res[3].message}
317317
end, {
318318
"Type mismatch: can not convert string('1') to integer"
319319
})
@@ -333,7 +333,7 @@ test:do_test(
333333
"builtins-2.22",
334334
function()
335335
local res = {pcall(box.execute, [[SELECT ZEROBLOB(?);]], {'1'})}
336-
return {tostring(res[3])}
336+
return {res[3].message}
337337
end, {
338338
"Type mismatch: can not convert string('1') to integer"
339339
})
@@ -353,7 +353,7 @@ test:do_test(
353353
"builtins-2.24",
354354
function()
355355
local res = {pcall(box.execute, [[SELECT SOUNDEX(?);]], {1})}
356-
return {tostring(res[3])}
356+
return {res[3].message}
357357
end, {
358358
"Type mismatch: can not convert integer(1) to string"
359359
})
@@ -373,7 +373,7 @@ test:do_test(
373373
"builtins-2.26",
374374
function()
375375
local res = {pcall(box.execute, [[SELECT UNICODE(?);]], {1})}
376-
return {tostring(res[3])}
376+
return {res[3].message}
377377
end, {
378378
"Type mismatch: can not convert integer(1) to string"
379379
})
@@ -393,7 +393,7 @@ test:do_test(
393393
"builtins-2.28",
394394
function()
395395
local res = {pcall(box.execute, [[SELECT ABS(?);]], {'1'})}
396-
return {tostring(res[3])}
396+
return {res[3].message}
397397
end, {
398398
"Type mismatch: can not convert string('1') to decimal"
399399
})
@@ -413,7 +413,7 @@ test:do_test(
413413
"builtins-2.30",
414414
function()
415415
local res = {pcall(box.execute, [[SELECT ROUND(?);]], {'1'})}
416-
return {tostring(res[3])}
416+
return {res[3].message}
417417
end, {
418418
"Type mismatch: can not convert string('1') to decimal"
419419
})
@@ -433,7 +433,7 @@ test:do_test(
433433
"builtins-2.32",
434434
function()
435435
local res = {pcall(box.execute, [[SELECT UUID(?);]], {'1'})}
436-
return {tostring(res[3])}
436+
return {res[3].message}
437437
end, {
438438
"Type mismatch: can not convert string('1') to integer"
439439
})
@@ -453,7 +453,7 @@ test:do_test(
453453
"builtins-2.34",
454454
function()
455455
local res = {pcall(box.execute, [[SELECT SUM(?);]], {'1'})}
456-
return {tostring(res[3])}
456+
return {res[3].message}
457457
end, {
458458
"Type mismatch: can not convert string('1') to decimal"
459459
})
@@ -473,7 +473,7 @@ test:do_test(
473473
"builtins-2.36",
474474
function()
475475
local res = {pcall(box.execute, [[SELECT AVG(?);]], {'1'})}
476-
return {tostring(res[3])}
476+
return {res[3].message}
477477
end, {
478478
"Type mismatch: can not convert string('1') to decimal"
479479
})
@@ -493,7 +493,7 @@ test:do_test(
493493
"builtins-2.38",
494494
function()
495495
local res = {pcall(box.execute, [[SELECT TOTAL(?);]], {'1'})}
496-
return {tostring(res[3])}
496+
return {res[3].message}
497497
end, {
498498
"Type mismatch: can not convert string('1') to decimal"
499499
})
@@ -590,7 +590,7 @@ test:do_test(
590590
"builtins-4.6",
591591
function()
592592
local res = {pcall(box.execute, [[SELECT LENGTH(?);]], {1})}
593-
return {tostring(res[3])}
593+
return {res[3].message}
594594
end, {
595595
"Type mismatch: can not convert integer(1) to string"
596596
})
@@ -615,7 +615,7 @@ test:do_test(
615615
"builtins-4.9",
616616
function()
617617
local res = {pcall(box.execute, [[SELECT POSITION(?, ?);]], {1, 1})}
618-
return {tostring(res[3])}
618+
return {res[3].message}
619619
end, {
620620
"Type mismatch: can not convert integer(1) to string"
621621
})
@@ -648,7 +648,7 @@ test:do_test(
648648
"builtins-4.13",
649649
function()
650650
local res = {pcall(box.execute, [[SELECT TOTAL(?);]], {'a'})}
651-
return {tostring(res[3])}
651+
return {res[3].message}
652652
end, {
653653
"Type mismatch: can not convert string('a') to decimal"
654654
})
@@ -657,7 +657,7 @@ test:do_test(
657657
"builtins-4.14",
658658
function()
659659
local res = {pcall(box.execute, [[SELECT TRIM(?);]], {1})}
660-
return {tostring(res[3])}
660+
return {res[3].message}
661661
end, {
662662
"Type mismatch: can not convert integer(1) to string"
663663
})

test/sql-tap/gh-2579-custom-aggregate.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ test:do_test(
8787
function()
8888
local def = {aggregate = 'group', exports = {'LUA', 'SQL'}}
8989
local res = {pcall(box.schema.func.create, 'F4', def)}
90-
return {tostring(res[2])}
90+
return {res[2].message}
9191
end, {
9292
"Failed to create function 'F4': aggregate function can only be "..
9393
"accessed in SQL"
@@ -99,7 +99,7 @@ test:do_test(
9999
function()
100100
local def = {aggregate = 'group', exports = {'SQL'}}
101101
local res = {pcall(box.schema.func.create, 'F4', def)}
102-
return {tostring(res[2])}
102+
return {res[2].message}
103103
end, {
104104
"Failed to create function 'F4': aggregate function must have at "..
105105
"least one argument"

test/sql-tap/index1.test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ test:do_test(
111111
end)
112112
v = v == true and {0} or {1}
113113
test:execsql("DROP TABLE test1")
114-
return table.insert(v,tostring(msg)) or v
114+
return table.insert(v, msg.message) or v
115115
end, {
116116
-- <index-2.2>
117117
1, "Can’t resolve field 'f4'"

test/sql-tap/lua/sqltester.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ local function catchsql(self, sql)
183183
else
184184
r[1] = 1
185185
if type(r[2]) == 'cdata' then
186-
r[2] = tostring(r[2])
186+
r[2] = r[2].message
187187
end
188188
end
189189
return r
@@ -274,7 +274,7 @@ local function catchsql2(self, sql)
274274
-- 1 means not ok
275275
r[1] = r[1] == true and 0 or 1
276276
if r[1] == 1 then
277-
r[2] = tostring(r[2])
277+
r[2] = r[2].message
278278
end
279279
return r
280280
end

0 commit comments

Comments
 (0)