|
1 | 1 | local t = require('luatest')
|
2 | 2 |
|
| 3 | +local json = require('json') |
| 4 | +local luatest_comparator = require('luatest.comparator') |
| 5 | + |
3 | 6 | local helpers = require('test.helper')
|
4 | 7 |
|
5 | 8 | local pgroup = t.group('schema', helpers.backend_matrix({
|
@@ -119,14 +122,37 @@ pgroup.test_timeout_option = function(g)
|
119 | 122 | t.assert_equals(err, nil)
|
120 | 123 | end
|
121 | 124 |
|
| 125 | +-- Lazy reimplementation of |
| 126 | +-- https://github.com/tarantool/luatest/pull/294 |
| 127 | +local function assert_one_of(t, actual, expected) |
| 128 | + local err_msg = nil |
| 129 | + local res = false |
| 130 | + for _, v in ipairs(expected) do |
| 131 | + if luatest_comparator.equals(actual, v) then |
| 132 | + res = true |
| 133 | + break |
| 134 | + end |
| 135 | + if err_msg == nil then |
| 136 | + err_msg = ("expected %s to be one of %s"):format(json.encode(expected), json.encode(v)) |
| 137 | + else |
| 138 | + err_msg = err_msg .. " ," .. json.encode(v) |
| 139 | + end |
| 140 | + end |
| 141 | + if not res then |
| 142 | + t.fail(err_msg) |
| 143 | + end |
| 144 | +end |
| 145 | + |
122 | 146 | pgroup.test_schema_cached = function(g)
|
123 | 147 | helpers.call_on_servers(g.cluster, {'s1-master', 's2-master'}, function(server)
|
124 | 148 | server:call('alter_schema')
|
125 | 149 | end)
|
126 | 150 |
|
| 151 | + -- We cannot guarantee net.box hadn't reloaded the schema, so |
| 152 | + -- it's either old or new. |
127 | 153 | local result_after, err = g.router:call('crud.schema', {nil, {cached = true}})
|
128 | 154 | t.assert_equals(err, nil)
|
129 |
| - t.assert_equals(result_after, expected_schema()) |
| 155 | + assert_one_of(t, result_after, {expected_schema(), altered_schema()}) |
130 | 156 | end
|
131 | 157 |
|
132 | 158 | pgroup.test_schema_reloaded = function(g)
|
|
0 commit comments