Skip to content
Snippets Groups Projects
Commit 902919ca authored by Alexander Turenko's avatar Alexander Turenko Committed by Alexander Turenko
Browse files

test/config: fix helper to use w/o extra config options

A set of testing helpers was added in commit 06ca83c9 ("test/config:
add several application script tests"). In particular, they allow to run
a tarantool instance with some default config file and write only
necessary config options in a test case.

In fact, if no options were set in the test, the config file was not
written. It is fixed in this commit and used in the next commit.

Part of #8862

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
parent ae441c99
No related branches found
No related tags found
No related merge requests found
......@@ -102,15 +102,17 @@ local function prepare_case(g, opts)
treegen.write_script(dir, 'main.lua', script)
end
local config = simple_config
if options ~= nil then
local config = table.deepcopy(simple_config)
config = table.deepcopy(simple_config)
for path, value in pairs(options) do
cluster_config:set(config, path, value)
end
treegen.write_script(dir, 'config.yaml', yaml.encode(config))
end
treegen.write_script(dir, 'config.yaml', yaml.encode(config))
local config_file = fio.pathjoin(dir, 'config.yaml')
local server = {
config_file = config_file,
chdir = dir,
......@@ -198,6 +200,7 @@ end
-- Verify test invariants after config:reload().
local function reload_success_case(g, opts)
local script_2 = assert(opts.script_2)
local options = assert(opts.options)
local verify_2 = assert(opts.verify_2)
local prepared = success_case(g, opts)
......@@ -205,6 +208,7 @@ local function reload_success_case(g, opts)
prepare_case(g, {
dir = prepared.dir,
script = script_2,
options = options,
})
g.server:exec(function()
local config = require('config')
......@@ -232,6 +236,7 @@ end
-- An error that config:reload() must raise.
local function reload_failure_case(g, opts)
local script_2 = assert(opts.script_2)
local options = assert(opts.options)
local exp_err = assert(opts.exp_err)
local prepared = success_case(g, opts)
......@@ -239,6 +244,7 @@ local function reload_failure_case(g, opts)
prepare_case(g, {
dir = prepared.dir,
script = script_2,
options = options,
})
t.assert_error_msg_equals(exp_err, g.server.exec, g.server, function()
local config = require('config')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment