From 570db47f06576307f52e6dd49074c0a086f4c269 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 15 Mar 2024 18:28:09 +0300 Subject: [PATCH] tests: reuse proper checks for type support Part of #422 --- test/entrypoint/srv_select/storage_init.lua | 10 +++------- test/helper.lua | 22 ++++++++++++++------- test/integration/read_scenario.lua | 9 +++++---- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/test/entrypoint/srv_select/storage_init.lua b/test/entrypoint/srv_select/storage_init.lua index 4e0208ee..cfcea23f 100644 --- a/test/entrypoint/srv_select/storage_init.lua +++ b/test/entrypoint/srv_select/storage_init.lua @@ -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() @@ -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'}, @@ -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'}, @@ -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, diff --git a/test/helper.lua b/test/helper.lua index 1bd0b281..24efb0e4 100644 --- a/test/helper.lua +++ b/test/helper.lua @@ -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, ...) diff --git a/test/integration/read_scenario.lua b/test/integration/read_scenario.lua index 968cd3af..667bfb31 100644 --- a/test/integration/read_scenario.lua +++ b/test/integration/read_scenario.lua @@ -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') @@ -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'), @@ -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,