Skip to content

Commit 8f97b6d

Browse files
ligurioTotktonada
authored andcommitted
Update tests for set and check sharding function with cdata
There are at least two ways for setting metadata for Lua cdata object: with and without ffi.new(). I found second way more clear because first one should use a function with placeholder instead of first argument and it looks a bit opaque for me. Follows up #71
1 parent 04f8ec1 commit 8f97b6d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

test/check_sharding_metadata_test.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ function g.test_user_sharding_func_cdata_call()
145145
int data;
146146
} test_check_struct_t;
147147
]]
148-
149-
local test_check_struct = ffi.metatype('test_check_struct_t', {
148+
ffi.metatype('test_check_struct_t', {
150149
__call = function(_, key) return key end
151150
})
152-
rawset(_G, user_sharding_func_name, test_check_struct())
151+
local test_check_struct = ffi.new('test_check_struct_t')
152+
rawset(_G, user_sharding_func_name, test_check_struct)
153153
g.space.sharding_func = user_sharding_func_name
154154

155155
local res, err = ddl.check_schema(g.schema)

test/set_sharding_metadata_test.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ function g.test_ddl_user_sharding_func_cdata_call()
424424
} test_set_struct_t;
425425
]]
426426

427-
local test_set_struct = ffi.metatype('test_set_struct_t', {
427+
ffi.metatype('test_set_struct_t', {
428428
__call = function(_, key) return key end
429429
})
430-
rawset(_G, user_sharding_func_name, test_set_struct())
430+
local test_set_struct = ffi.new('test_set_struct_t')
431+
rawset(_G, user_sharding_func_name, test_set_struct)
431432
space_one.sharding_func = user_sharding_func_name
432433

433434
local schema = {

0 commit comments

Comments
 (0)