Skip to content

Commit 2d22046

Browse files
committed
test: fix luacheck warnings on test files
1 parent 4280405 commit 2d22046

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

test/mysql.test.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ if conn == nil then error(err) end
1717

1818
local p, err = mysql.pool_create({ host = host, port = port, user = user,
1919
password = password, db = db, size = 2 })
20+
if p == nil then error(err) end
2021

21-
function test_old_api(t, conn)
22+
local function test_old_api(t, conn)
2223
t:plan(16)
2324
-- Add an extension to 'tap' module
2425
getmetatable(t).__index.q = function(test, stmt, result, ...)
@@ -63,12 +64,12 @@ function test_old_api(t, conn)
6364
end)
6465

6566
t:q('DROP TABLE IF EXISTS unknown_table', nil)
66-
local status, reason = pcall(conn.execute, conn, 'DROP TABLE unknown_table')
67+
local _, reason = pcall(conn.execute, conn, 'DROP TABLE unknown_table')
6768
t:like(reason, 'unknown_table', 'error')
6869
t:ok(conn:close(), "close")
6970
end
7071

71-
function test_gc(test, pool)
72+
local function test_gc(test, pool)
7273
test:plan(3)
7374

7475
-- Case: verify that a pool tracks connections that are not
@@ -82,7 +83,7 @@ function test_gc(test, pool)
8283
pool:get()
8384

8485
-- Loss another one.
85-
local conn = pool:get()
86+
local conn = pool:get() -- luacheck: no unused
8687
conn = nil
8788

8889
-- Collect lost connections.
@@ -103,7 +104,7 @@ function test_gc(test, pool)
103104
local conn = pool:get()
104105
local ok = pcall(conn.execute, conn, 'bad query')
105106
test:ok(not ok, 'a query actually fails')
106-
conn = nil
107+
conn = nil -- luacheck: no unused
107108

108109
-- Collect the lost connection.
109110
collectgarbage('collect')
@@ -121,7 +122,7 @@ function test_gc(test, pool)
121122
-- Get a connection, close it and loss the connection.
122123
local conn = pool:get()
123124
conn:close()
124-
conn = nil
125+
conn = nil -- luacheck: no unused
125126

126127
-- Collect the lost connection.
127128
collectgarbage('collect')
@@ -131,21 +132,21 @@ function test_gc(test, pool)
131132
end)
132133
end
133134

134-
function test_conn_fiber1(c, q)
135-
for i = 1, 10 do
135+
local function test_conn_fiber1(c, q)
136+
for _ = 1, 10 do
136137
c:execute('SELECT sleep(0.05)')
137138
end
138139
q:put(true)
139140
end
140141

141-
function test_conn_fiber2(c, q)
142-
for i = 1, 25 do
142+
local function test_conn_fiber2(c, q)
143+
for _ = 1, 25 do
143144
c:execute('SELECT sleep(0.02)')
144145
end
145146
q:put(true)
146147
end
147148

148-
function test_conn_concurrent(t, p)
149+
local function test_conn_concurrent(t, p)
149150
t:plan(1)
150151
local c = p:get()
151152
local q = fiber.channel(2)
@@ -158,13 +159,12 @@ function test_conn_concurrent(t, p)
158159
t:ok(fiber.time() - t1 >= 0.95, 'concurrent connections')
159160
end
160161

161-
162-
function test_mysql_int64(t, p)
162+
local function test_mysql_int64(t, p)
163163
t:plan(1)
164-
conn = p:get()
164+
local conn = p:get()
165165
conn:execute('create table int64test (id bigint)')
166166
conn:execute('insert into int64test values(1234567890123456789)')
167-
local d, s = conn:execute('select id from int64test')
167+
local d, _ = conn:execute('select id from int64test')
168168
conn:execute('drop table int64test')
169169
t:ok(d[1][1]['id'] == 1234567890123456789LL, 'int64 test')
170170
p:put(conn)
@@ -179,7 +179,7 @@ local function test_connection_pool(test, pool)
179179

180180
-- Grab all connections from a pool.
181181
local connections = {}
182-
for i = 1, pool.size do
182+
for _ = 1, pool.size do
183183
table.insert(connections, pool:get())
184184
end
185185

@@ -206,7 +206,7 @@ local function test_connection_pool(test, pool)
206206

207207
-- Restore everything as it was.
208208
table.insert(connections, conn)
209-
conn = nil
209+
conn = nil -- luacheck: no unused
210210

211211
assert(pool.queue:is_empty(), 'test case postcondition fails')
212212
end)
@@ -295,7 +295,7 @@ local function test_connection_pool(test, pool)
295295

296296
-- Put the connection back, loss it and trigger GC.
297297
pool:put(conn)
298-
conn = nil
298+
conn = nil -- luacheck: no unused
299299
collectgarbage('collect')
300300

301301
-- Verify that the pool is full.
@@ -339,7 +339,7 @@ local function test_connection_pool(test, pool)
339339

340340
-- Put the connection back, loss it and trigger GC.
341341
pool:put(conn)
342-
conn = nil
342+
conn = nil -- luacheck: no unused
343343
collectgarbage('collect')
344344

345345
-- Verify that the pool is full

test/numeric_result.test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local p, err = mysql.pool_create({ host = host, port = port, user = user,
1717
password = password, db = db, size = 1, use_numeric_result = true })
1818
if p == nil then error(err) end
1919

20-
function test_mysql_numeric_result(t, conn)
20+
local function test_mysql_numeric_result(t, conn)
2121
t:plan(1)
2222

2323
-- Prepare a table.

0 commit comments

Comments
 (0)