Skip to content
Snippets Groups Projects
Commit 40aa4df6 authored by Gleb Kashkin's avatar Gleb Kashkin Committed by Alexander Turenko
Browse files

test: add error rethrow to :read_response() in `it`

Before this patch interactive_tarantool `:read_response()` helper used
to just deserialise Lua errors as tables like `[{error = 'msg'}]`.
Now it checks if response is actually an error and rethrows it.
This provides additional verification for many tests that use
interactive_tarantool.

This patch is a followup to commit 261a21bd ("test/config: adjust
initial permissions in a test"). It provides additional output checks
to prevent similar issues.

Part of #8967

NO_DOC=test helper update
NO_CHANGELOG=test helper update
NO_TEST=test helper update

(cherry picked from commit 793713e6)
parent 2ecabd56
No related branches found
No related tags found
No related merge requests found
......@@ -246,6 +246,21 @@ function mt.read_response(self, opts)
local raw_reply = '---\n' .. table.concat(lines, '\n') .. '\n'
local reply = yaml.decode(raw_reply)
-- Consider reply an error if the following conditions are met:
--
-- 1. The reply contains just one response.
-- 2. The response is a table.
-- 3. The table contains only one key.
-- 4. This key is 'error'.
--
-- This is how tarantool's console serializes a raised error.
local is_error = #reply == 1 and type(reply[1]) == 'table' and
next(reply[1], next(reply[1])) == nil and reply[1].error ~= nil
if is_error then
error(reply[1].error, 0)
end
return unpack(reply, 1, table.maxn(reply))
end
......
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