Skip to content

Commit

Permalink
lua: fix code style it test scripts
Browse files Browse the repository at this point in the history
Added standard .luacheckrc config. Added indentation to box.once blocks.
Fix trailing spaces and add missing spaces to mathematical expressions.
Set global variables through rawset.
  • Loading branch information
DifferentialOrange committed Feb 3, 2022
1 parent 81a13e3 commit 491e9aa
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
redefined = false
globals = {'box', 'utf8', 'checkers', '_TARANTOOL'}
include_files = {'**/*.lua', '*.luacheckrc', '*.rockspec'}
exclude_files = {'**/*.rocks/'}
max_line_length = 120
87 changes: 44 additions & 43 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,56 @@ box.cfg{
}

box.once("init", function()
local s = box.schema.space.create('test', {
id = 512,
if_not_exists = true,
})
s:create_index('primary', {type = 'tree', parts = {1, 'uint'}, if_not_exists = true})
local s = box.schema.space.create('test', {
id = 512,
if_not_exists = true,
})
s:create_index('primary', {type = 'tree', parts = {1, 'uint'}, if_not_exists = true})

local st = box.schema.space.create('schematest', {
id = 514,
temporary = true,
if_not_exists = true,
field_count = 7,
format = {
{name = "name0", type = "unsigned"},
{name = "name1", type = "unsigned"},
{name = "name2", type = "string"},
{name = "name3", type = "unsigned"},
{name = "name4", type = "unsigned"},
{name = "name5", type = "string"},
},
})
st:create_index('primary', {
type = 'hash',
parts = {1, 'uint'},
unique = true,
if_not_exists = true,
})
st:create_index('secondary', {
id = 3,
type = 'tree',
unique = false,
parts = { 2, 'uint', 3, 'string' },
if_not_exists = true,
})
st:truncate()
local st = box.schema.space.create('schematest', {
id = 514,
temporary = true,
if_not_exists = true,
field_count = 7,
format = {
{name = "name0", type = "unsigned"},
{name = "name1", type = "unsigned"},
{name = "name2", type = "string"},
{name = "name3", type = "unsigned"},
{name = "name4", type = "unsigned"},
{name = "name5", type = "string"},
},
})
st:create_index('primary', {
type = 'hash',
parts = {1, 'uint'},
unique = true,
if_not_exists = true,
})
st:create_index('secondary', {
id = 3,
type = 'tree',
unique = false,
parts = { 2, 'uint', 3, 'string' },
if_not_exists = true,
})
st:truncate()

--box.schema.user.grant('guest', 'read,write,execute', 'universe')
box.schema.func.create('box.info')
box.schema.func.create('simple_incr')
--box.schema.user.grant('guest', 'read,write,execute', 'universe')
box.schema.func.create('box.info')
box.schema.func.create('simple_incr')

-- auth testing: access control
box.schema.user.create('test', {password = 'test'})
box.schema.user.grant('test', 'execute', 'universe')
box.schema.user.grant('test', 'read,write', 'space', 'test')
box.schema.user.grant('test', 'read,write', 'space', 'schematest')
-- auth testing: access control
box.schema.user.create('test', {password = 'test'})
box.schema.user.grant('test', 'execute', 'universe')
box.schema.user.grant('test', 'read,write', 'space', 'test')
box.schema.user.grant('test', 'read,write', 'space', 'schematest')
end)

function simple_incr(a)
return a+1
local function simple_incr(a)
return a + 1
end
rawset(_G, 'simple_incr', simple_incr)

box.space.test:truncate()

Expand Down
3 changes: 2 additions & 1 deletion multi/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ box.cfg{
}

-- Function to call for getting address list, part of tarantool/multi API.
get_cluster_nodes = nodes_load.get_cluster_nodes
local get_cluster_nodes = nodes_load.get_cluster_nodes
rawset(_G, 'get_cluster_nodes', get_cluster_nodes)

box.once("init", function()
box.schema.user.create('test', { password = 'test' })
Expand Down
79 changes: 40 additions & 39 deletions queue/config.lua
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
queue = require('queue')
local queue = require('queue')
rawset(_G, 'queue', queue)

-- Do not set listen for now so connector won't be
-- able to send requests until everything is configured.
box.cfg{
work_dir = os.getenv("TEST_TNT_WORK_DIR"),
}

box.once("init", function()
box.schema.user.create('test', {password = 'test'})
box.schema.func.create('queue.tube.test_queue:ack')
box.schema.func.create('queue.tube.test_queue:put')
box.schema.func.create('queue.tube.test_queue:drop')
box.schema.func.create('queue.tube.test_queue:peek')
box.schema.func.create('queue.tube.test_queue:kick')
box.schema.func.create('queue.tube.test_queue:take')
box.schema.func.create('queue.tube.test_queue:delete')
box.schema.func.create('queue.tube.test_queue:release')
box.schema.func.create('queue.tube.test_queue:bury')
box.schema.func.create('queue.statistics')
box.schema.user.grant('test', 'create', 'space')
box.schema.user.grant('test', 'write', 'space', '_schema')
box.schema.user.grant('test', 'write', 'space', '_space')
box.schema.user.grant('test', 'read,write', 'space', '_space_sequence')
box.schema.user.grant('test', 'write', 'space', '_index')
box.schema.user.grant('test', 'read, write', 'space', '_queue_session_ids')
box.schema.user.grant('test', 'execute', 'universe')
box.schema.user.grant('test', 'read,write', 'space', '_queue')
box.schema.user.grant('test', 'read,write', 'space', '_schema')
box.schema.user.grant('test', 'read,write', 'space', '_space')
box.schema.user.grant('test', 'read,write', 'space', '_index')
box.schema.user.grant('test', 'read,write', 'space', '_queue_consumers')
box.schema.user.grant('test', 'read,write', 'space', '_priv')
box.schema.user.grant('test', 'read,write', 'space', '_queue_taken_2')
if box.space._trigger ~= nil then
box.schema.user.grant('test', 'read', 'space', '_trigger')
end
if box.space._fk_constraint ~= nil then
box.schema.user.grant('test', 'read', 'space', '_fk_constraint')
end
if box.space._ck_constraint ~= nil then
box.schema.user.grant('test', 'read', 'space', '_ck_constraint')
end
if box.space._func_index ~= nil then
box.schema.user.grant('test', 'read', 'space', '_func_index')
end
box.once("init", function()
box.schema.user.create('test', {password = 'test'})
box.schema.func.create('queue.tube.test_queue:ack')
box.schema.func.create('queue.tube.test_queue:put')
box.schema.func.create('queue.tube.test_queue:drop')
box.schema.func.create('queue.tube.test_queue:peek')
box.schema.func.create('queue.tube.test_queue:kick')
box.schema.func.create('queue.tube.test_queue:take')
box.schema.func.create('queue.tube.test_queue:delete')
box.schema.func.create('queue.tube.test_queue:release')
box.schema.func.create('queue.tube.test_queue:bury')
box.schema.func.create('queue.statistics')
box.schema.user.grant('test', 'create', 'space')
box.schema.user.grant('test', 'write', 'space', '_schema')
box.schema.user.grant('test', 'write', 'space', '_space')
box.schema.user.grant('test', 'read,write', 'space', '_space_sequence')
box.schema.user.grant('test', 'write', 'space', '_index')
box.schema.user.grant('test', 'read, write', 'space', '_queue_session_ids')
box.schema.user.grant('test', 'execute', 'universe')
box.schema.user.grant('test', 'read,write', 'space', '_queue')
box.schema.user.grant('test', 'read,write', 'space', '_schema')
box.schema.user.grant('test', 'read,write', 'space', '_space')
box.schema.user.grant('test', 'read,write', 'space', '_index')
box.schema.user.grant('test', 'read,write', 'space', '_queue_consumers')
box.schema.user.grant('test', 'read,write', 'space', '_priv')
box.schema.user.grant('test', 'read,write', 'space', '_queue_taken_2')
if box.space._trigger ~= nil then
box.schema.user.grant('test', 'read', 'space', '_trigger')
end
if box.space._fk_constraint ~= nil then
box.schema.user.grant('test', 'read', 'space', '_fk_constraint')
end
if box.space._ck_constraint ~= nil then
box.schema.user.grant('test', 'read', 'space', '_ck_constraint')
end
if box.space._func_index ~= nil then
box.schema.user.grant('test', 'read', 'space', '_func_index')
end
end)

-- Set listen only when every other thing is configured.
Expand Down

0 comments on commit 491e9aa

Please sign in to comment.