|
| 1 | +local t = require('luatest') |
| 2 | +local checks = require('checks') |
| 3 | + |
| 4 | +-- Scenario is for 'srv_batch_operations' entrypoint. |
| 5 | +local function gh_437_many_explicit_bucket_ids(cg, operation, opts) |
| 6 | + checks('table', 'string', { |
| 7 | + objects = '?boolean', |
| 8 | + upsert = '?boolean', |
| 9 | + partial_explicit_bucket_ids = '?boolean', |
| 10 | + }) |
| 11 | + |
| 12 | + opts = opts or {} |
| 13 | + |
| 14 | + local rows = { |
| 15 | + {1, 1, 'Kumiko', 18}, |
| 16 | + {2, 2, 'Reina', 19}, |
| 17 | + {3, 3, 'Shuuichi', 18}, |
| 18 | + } |
| 19 | + |
| 20 | + if opts.partial_explicit_bucket_ids then |
| 21 | + rows[2][2] = box.NULL |
| 22 | + end |
| 23 | + |
| 24 | + local objects = {} |
| 25 | + for k, v in ipairs(rows) do |
| 26 | + objects[k] = {id = v[1], bucket_id = v[2], name = v[3], age = v[4]} |
| 27 | + end |
| 28 | + |
| 29 | + local data |
| 30 | + if opts.objects then |
| 31 | + data = objects |
| 32 | + else |
| 33 | + data = rows |
| 34 | + end |
| 35 | + |
| 36 | + if opts.upsert then |
| 37 | + local update_operations = {} |
| 38 | + for k, v in ipairs(data) do |
| 39 | + data[k] = {v, update_operations} |
| 40 | + end |
| 41 | + end |
| 42 | + |
| 43 | + local args = {'customers_sharded_by_age', data} |
| 44 | + |
| 45 | + local result, errs = cg.router:call('crud.' .. operation, args) |
| 46 | + t.assert_equals(errs, nil) |
| 47 | + |
| 48 | + local result_rows = table.deepcopy(rows) |
| 49 | + if opts.partial_explicit_bucket_ids then |
| 50 | + result_rows[2][2] = 1325 |
| 51 | + end |
| 52 | + if opts.upsert then |
| 53 | + -- upsert never return anything. |
| 54 | + t.assert_equals(result.rows, nil) |
| 55 | + else |
| 56 | + t.assert_items_equals(result.rows, result_rows) |
| 57 | + end |
| 58 | +end |
| 59 | + |
| 60 | +return { |
| 61 | + gh_437_many_explicit_bucket_ids = gh_437_many_explicit_bucket_ids, |
| 62 | +} |
0 commit comments