forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Oleg Chaplashkin
committed
May 31, 2023
1 parent
0ef5e3b
commit da9ec9a
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- There are situations when the Tarantool instance is configured | ||
-- for testing. For example: | ||
-- | ||
-- g.test_foo = function() | ||
-- box.cfg{params} | ||
-- ... | ||
-- t.assert_equals(foo, bar) | ||
-- | ||
-- g.test_bar = function() | ||
-- t.assert_equals(foo, bar) | ||
-- | ||
-- We expect that the test environment will not be configured | ||
-- in the `test_bar`, but this will not always be the case | ||
-- (depends on the order of execution of tests). | ||
-- We prohibit a direct call to `box.cfg` by overriding the | ||
-- `__call` meta method. | ||
box.cfg = setmetatable({}, {__call = function() | ||
error('A direct call to `box.cfg` is not recommended' .. | ||
' (you are changing the test runner instance)', 0) end}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters