Skip to content

Commit

Permalink
Add test for part count check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Nikiforov committed Dec 21, 2020
1 parent 10c00a9 commit 877d87b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/tuple_keydef.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ local tuple_keydef_new_cases = {

local test = tap.test('tuple.keydef')

test:plan(#tuple_keydef_new_cases - 1 + 8)
test:plan(#tuple_keydef_new_cases - 1 + 8 + 1)
for _, case in ipairs(tuple_keydef_new_cases) do
if type(case) == 'function' then
case()
Expand Down Expand Up @@ -604,4 +604,26 @@ test:test('JSON path is not supported error', function(test)
'verify error message')
end)

-- Copied from tarantool proper
test:test('key_def part count tests', function(test)
test:plan(3)

local kd = tuple_keydef.new({{fieldno = 1, type = 'unsigned'}})
local ok, res

-- Should succeed
ok, res = pcall(kd.compare_with_key, kd, {1}, {1})
test:ok(ok and res == 0, "Simple equality")

-- Should succeed
ok, res = pcall(kd.compare_with_key, kd, {1}, {2})
test:ok(ok and res < 0, "Simple inequality")

-- Should fail
local exp_err = "Invalid key part count (expected [0..1], got 9)"
ok, res = pcall(kd.compare_with_key, kd, {1}, {1, 2, 3, 4, 5, 6, 7, 8, 9})
test:is_deeply({ok, tostring(res)}, {false, exp_err},
"Invalid key part count")
end)

os.exit(test:check() and 0 or 1)

0 comments on commit 877d87b

Please sign in to comment.