Skip to content

Commit

Permalink
tests: reuse proper checks for type support
Browse files Browse the repository at this point in the history
Part of #422
  • Loading branch information
DifferentialOrange committed Mar 18, 2024
1 parent cae3fb6 commit 3fdd950
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
10 changes: 3 additions & 7 deletions test/entrypoint/srv_select/storage_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
local datetime_supported, datetime = pcall(require, 'datetime')
local decimal_supported, _ = pcall(require, 'decimal')

local crud_utils = require('crud.common.utils')

return function()
Expand Down Expand Up @@ -231,7 +228,7 @@ return function()
if_not_exists = true,
})

if decimal_supported then
if crud_utils.tarantool_supports_decimals() then
local decimal_format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
Expand Down Expand Up @@ -327,7 +324,7 @@ return function()
})
end

if datetime_supported then
if crud_utils.tarantool_supports_datetimes() then
local datetime_format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
Expand Down Expand Up @@ -423,8 +420,7 @@ return function()
})
end

local interval_supported = datetime_supported and (datetime.interval ~= nil)
if interval_supported then
if crud_utils.tarantool_supports_intervals() then
-- Interval is non-indexable.
local interval_space = box.schema.space.create('interval', {
if_not_exists = true,
Expand Down
22 changes: 15 additions & 7 deletions test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -958,20 +958,28 @@ function helpers.prepare_ordered_data(g, space, expected_objects, bucket_id, ord
t.assert_equals(objects, expected_objects)
end

function helpers.is_decimal_supported()
return crud_utils.tarantool_supports_decimals()
end

function helpers.is_datetime_supported()
return crud_utils.tarantool_supports_datetimes()
end

function helpers.is_interval_supported()
return crud_utils.tarantool_supports_intervals()
end

function helpers.skip_decimal_unsupported()
local module_available, _ = pcall(require, 'decimal')
t.skip_if(not module_available, 'decimal is not supported')
t.skip_if(not helpers.is_decimal_supported(), 'decimal is not supported')
end

function helpers.skip_datetime_unsupported()
local module_available, _ = pcall(require, 'datetime')
t.skip_if(not module_available, 'datetime is not supported')
t.skip_if(not helpers.is_datetime_supported(), 'datetime is not supported')
end

function helpers.skip_interval_unsupported()
local datetime_supported, datetime = pcall(require, 'datetime')
local interval_supported = datetime_supported and (datetime.interval ~= nil)
t.skip_if(not interval_supported, 'interval is not supported')
t.skip_if(not helpers.is_interval_supported(), 'interval is not supported')
end

function helpers.merge_tables(t1, t2, ...)
Expand Down
9 changes: 5 additions & 4 deletions test/integration/read_scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
-- Scenarios here are for `srv_select` entrypoint.

local t = require('luatest')
local datetime_supported, datetime = pcall(require, 'datetime')
local decimal_supported, decimal = pcall(require, 'decimal')

local _, datetime = pcall(require, 'datetime')
local _, decimal = pcall(require, 'decimal')

local helpers = require('test.helper')

Expand Down Expand Up @@ -98,7 +99,7 @@ end

local decimal_vals = {}

if decimal_supported then
if helpers.is_decimal_supported() then
decimal_vals = {
smallest_negative = decimal.new('-123456789012345678.987431234678392'),
bigger_negative = decimal.new('-123456789012345678.987431234678391'),
Expand Down Expand Up @@ -318,7 +319,7 @@ end

local datetime_vals = {}

if datetime_supported then
if helpers.is_datetime_supported() then
datetime_vals = {
yesterday = datetime.new{
year = 2024,
Expand Down

0 comments on commit 3fdd950

Please sign in to comment.