Skip to content

Commit 9a63cf4

Browse files
author
Oleg Chaplashkin
committed
test: ban direct calling of box.cfg()
Direct call and configuration of the runner instance is prohibited. Now if you need to test something with specific configuration use a server instance please (see luatest.Server module). In-scope-of tarantool/luatest#245 NO_DOC=ban calling box.cfg NO_TEST=ban calling box.cfg NO_CHANGELOG=ban calling box.cfg
1 parent 606e50c commit 9a63cf4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/helper.lua

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- There are situations when the Tarantool instance is configured
2+
-- for testing. For example:
3+
--
4+
-- g.test_foo = function()
5+
-- box.cfg{params}
6+
-- ...
7+
-- t.assert_equals(foo, bar)
8+
--
9+
-- g.test_bar = function()
10+
-- t.assert_equals(foo, bar)
11+
--
12+
-- We expect that the test environment will not be configured
13+
-- in the `test_bar` test, but this will not always be the case
14+
-- (depends on the order of execution of tests).
15+
-- We prohibit a direct call to `box.cfg` by overriding the
16+
-- `__call` meta method. Motivating issue tarantool/luatest#245.
17+
box.cfg = setmetatable({}, {__call = function()
18+
error('A direct call to `box.cfg` is forbidden' ..
19+
' (you are changing the test runner instance)', 0)
20+
end})

0 commit comments

Comments
 (0)