Skip to content

Commit 453983b

Browse files
test: check count erroneous early exit
The test was missing from PR #419, which had solved the original issue. Follows #418
1 parent 781f3c4 commit 453983b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

test/integration/count_test.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local clock = require('clock')
33
local t = require('luatest')
44

55
local helpers = require('test.helper')
6+
local read_scenario = require('test.integration.read_scenario')
67

78
local pgroup = t.group('count', helpers.backend_matrix({
89
{engine = 'memtx'},
@@ -867,3 +868,17 @@ pgroup.test_count_force_map_call = function(g)
867868
t.assert_equals(err, nil)
868869
t.assert_equals(result, 2)
869870
end
871+
872+
pgroup.test_gh_418_count_with_secondary_noneq_index_condition = function(g)
873+
local read = function(cg, space, conditions, opts)
874+
opts = table.deepcopy(opts) or {}
875+
opts.mode = 'write'
876+
877+
local resp, err = cg.cluster.main_server:call('crud.count', {space, conditions, opts})
878+
t.assert_equals(err, nil)
879+
880+
return resp
881+
end
882+
883+
read_scenario.gh_418_read_with_secondary_noneq_index_condition(g, read)
884+
end

test/integration/read_scenario.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- crud.select/crud.pairs/readview:select/readview:pairs
1+
-- crud.select/crud.pairs/crud.count/readview:select/readview:pairs
22
-- have a lot of common scenarios, which are mostly tested with
33
-- four nearly identical copypasted test functions now.
44
-- This approach is expected to improve it at least for new test cases.
@@ -48,13 +48,17 @@ local function gh_418_read_with_secondary_noneq_index_condition(cg, read)
4848
-- iterator had erroneously expected tuples to be sorted by `last_login`
4949
-- index while iterating on `city` index. Before the issue had beed fixed,
5050
-- user had received only one record instead of two.
51-
local objects = read(cg,
51+
local result = read(cg,
5252
'logins',
5353
{{'=', 'city', 'Tatsumi Port Island'}, {'<=', 'last_login', 42}},
5454
{bucket_id = PINNED_BUCKET_NO}
5555
)
5656

57-
t.assert_equals(objects, {expected_objects[1], expected_objects[3]})
57+
if type(result) == 'number' then -- crud.count
58+
t.assert_equals(result, 2)
59+
else
60+
t.assert_equals(result, {expected_objects[1], expected_objects[3]})
61+
end
5862
end
5963

6064
return {

0 commit comments

Comments
 (0)