Skip to content

Commit

Permalink
test: check count erroneous early exit
Browse files Browse the repository at this point in the history
The test was missing from PR #419, which had solved the original issue.

Follows #418
  • Loading branch information
DifferentialOrange committed Mar 14, 2024
1 parent 8237ebd commit f30a343
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 15 additions & 0 deletions test/integration/count_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local clock = require('clock')
local t = require('luatest')

local helpers = require('test.helper')
local read_scenario = require('test.integration.read_scenario')

local pgroup = t.group('count', helpers.backend_matrix({
{engine = 'memtx'},
Expand Down Expand Up @@ -867,3 +868,17 @@ pgroup.test_count_force_map_call = function(g)
t.assert_equals(err, nil)
t.assert_equals(result, 2)
end

pgroup.test_gh_418_count_with_secondary_noneq_index_condition = function(g)
local read = function(cg, space, conditions, opts)
opts = table.deepcopy(opts) or {}
opts.mode = 'write'

local resp, err = cg.cluster.main_server:call('crud.count', {space, conditions, opts})
t.assert_equals(err, nil)

return resp
end

read_scenario.gh_418_read_with_secondary_noneq_index_condition(g, read)
end
10 changes: 7 additions & 3 deletions test/integration/read_scenario.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- crud.select/crud.pairs/readview:select/readview:pairs
-- crud.select/crud.pairs/crud.count/readview:select/readview:pairs
-- have a lot of common scenarios, which are mostly tested with
-- four nearly identical copypasted test functions now.
-- This approach is expected to improve it at least for new test cases.
Expand Down Expand Up @@ -48,13 +48,17 @@ local function gh_418_read_with_secondary_noneq_index_condition(cg, read)
-- iterator had erroneously expected tuples to be sorted by `last_login`
-- index while iterating on `city` index. Before the issue had beed fixed,
-- user had received only one record instead of two.
local objects = read(cg,
local result = read(cg,
'logins',
{{'=', 'city', 'Tatsumi Port Island'}, {'<=', 'last_login', 42}},
{bucket_id = PINNED_BUCKET_NO}
)

t.assert_equals(objects, {expected_objects[1], expected_objects[3]})
if type(result) == 'number' then -- crud.count
t.assert_equals(result, 2)
else
t.assert_equals(result, {expected_objects[1], expected_objects[3]})
end
end

return {
Expand Down

0 comments on commit f30a343

Please sign in to comment.