@@ -4,7 +4,6 @@ local t = require('luatest')
44local g_memtx = t .group (' pairs_memtx' )
55local g_vinyl = t .group (' pairs_vinyl' )
66
7- local crud = require (' crud' )
87local crud_utils = require (' crud.common.utils' )
98
109local helpers = require (' test.helper' )
@@ -84,32 +83,8 @@ local function add(name, fn)
8483 g_vinyl [name ] = fn
8584end
8685
87- local function insert_customers (g , customers )
88- local inserted_objects = {}
89-
90- for _ , customer in ipairs (customers ) do
91- local result , err = g .cluster .main_server .net_box :call (' crud.insert_object' , {' customers' , customer })
92- t .assert_equals (err , nil )
93-
94- local objects , err = crud .unflatten_rows (result .rows , result .metadata )
95- t .assert_equals (err , nil )
96- t .assert_equals (# objects , 1 )
97- table.insert (inserted_objects , objects [1 ])
98- end
99-
100- return inserted_objects
101- end
102-
103- local function get_by_ids (customers , ids )
104- local results = {}
105- for _ , id in ipairs (ids ) do
106- table.insert (results , customers [id ])
107- end
108- return results
109- end
110-
11186add (' test_pairs_no_conditions' , function (g )
112- local customers = insert_customers ( g , {
87+ local customers = helpers . insert_objects ( g , ' customers ' , {
11388 {
11489 id = 1 , name = " Elizabeth" , last_name = " Jackson" ,
11590 age = 12 , city = " New York" ,
@@ -190,7 +165,7 @@ add('test_pairs_no_conditions', function(g)
190165 ]] , {after })
191166
192167 t .assert_equals (err , nil )
193- t .assert_equals (objects , get_by_ids (customers , {3 , 4 }))
168+ t .assert_equals (objects , helpers . get_objects_by_idxs (customers , {3 , 4 }))
194169
195170 -- after obj 4 (last)
196171 local after = crud_utils .flatten (customers [4 ], g .space_format )
@@ -212,7 +187,7 @@ add('test_pairs_no_conditions', function(g)
212187end )
213188
214189add (' test_ge_condition_with_index' , function (g )
215- local customers = insert_customers ( g , {
190+ local customers = helpers . insert_objects ( g , ' customers ' , {
216191 {
217192 id = 1 , name = " Elizabeth" , last_name = " Jackson" ,
218193 age = 12 , city = " New York" ,
@@ -249,7 +224,7 @@ add('test_ge_condition_with_index', function(g)
249224 ]] , {conditions })
250225
251226 t .assert_equals (err , nil )
252- t .assert_equals (objects , get_by_ids (customers , {3 , 2 , 4 })) -- in age order
227+ t .assert_equals (objects , helpers . get_objects_by_idxs (customers , {3 , 2 , 4 })) -- in age order
253228
254229 -- after obj 3
255230 local after = crud_utils .flatten (customers [3 ], g .space_format )
@@ -267,11 +242,11 @@ add('test_ge_condition_with_index', function(g)
267242 ]] , {conditions , after })
268243
269244 t .assert_equals (err , nil )
270- t .assert_equals (objects , get_by_ids (customers , {2 , 4 })) -- in age order
245+ t .assert_equals (objects , helpers . get_objects_by_idxs (customers , {2 , 4 })) -- in age order
271246end )
272247
273248add (' test_le_condition_with_index' , function (g )
274- local customers = insert_customers ( g , {
249+ local customers = helpers . insert_objects ( g , ' customers ' , {
275250 {
276251 id = 1 , name = " Elizabeth" , last_name = " Jackson" ,
277252 age = 12 , city = " New York" ,
@@ -308,7 +283,7 @@ add('test_le_condition_with_index', function(g)
308283 ]] , {conditions })
309284
310285 t .assert_equals (err , nil )
311- t .assert_equals (objects , get_by_ids (customers , {3 , 1 })) -- in age order
286+ t .assert_equals (objects , helpers . get_objects_by_idxs (customers , {3 , 1 })) -- in age order
312287
313288 -- after obj 3
314289 local after = crud_utils .flatten (customers [3 ], g .space_format )
@@ -326,11 +301,11 @@ add('test_le_condition_with_index', function(g)
326301 ]] , {conditions , after })
327302
328303 t .assert_equals (err , nil )
329- t .assert_equals (objects , get_by_ids (customers , {1 })) -- in age order
304+ t .assert_equals (objects , helpers . get_objects_by_idxs (customers , {1 })) -- in age order
330305end )
331306
332307add (' test_negative_first' , function (g )
333- local customers = insert_customers ( g ,{
308+ local customers = helpers . insert_objects ( g , ' customers ' ,{
334309 {
335310 id = 1 , name = " Elizabeth" , last_name = " Jackson" ,
336311 age = 12 , city = " New York" ,
0 commit comments