Skip to content
Snippets Groups Projects
user avatar
Alexander Turenko authored
Before this patch the `:roundtrip()` method in the
`test.interative_tarantool` instance considered the following calls as
equivalent:

```lua
g.it = it.new()

-- Doesn't check the response.
g.it:roundtrip('x')

-- Before the patch it was the same as above.
--
-- Now it checks that the response is nil.
local expected = nil
g.it:roundtrip('x', expected)

-- It is the same as previous.
g.it:roundtrip('x', nil)
```

Now the response is checked against the provided expected value if the
value is passed to arguments, even if it is `nil`.

Also, a command's response is now returned from the method. It may be
useful if the response returns some dynamic information (such as a TCP
port number or a file descriptor) that is used later in the test or if
the response should be verified in some non-trivial way, not just a deep
compare.

The `:roundtrip()` method is just `:execute_command()` plus
`:read_response()` plus `luatest.assert_equals()`. However, I like using
`:roundtrip()` even when the assertion is not needed, because it is
shorter and because using the same method brings less context to a
reader.

For example,

```lua
g.it = it.new()
g.it:roundtrip('x = 2')
g.it:roundtrip('y = 3')
g.it:roundtrip('x + y', 6)
```

Part of #9985

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
7d9e8569
History
user avatar 7d9e8569
Name Last commit Last update