Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 392f08b

Browse files
committed
Make tests unaware of next() order
Rewritten using tap output and using is_deeply() a lot. Some tests moved from 'space' test suite to 'common' to being run on several configurations.
1 parent ab7e4da commit 392f08b

39 files changed

+1028
-1319
lines changed

graphql/tarantool_graphql.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,10 +1350,10 @@ local function stop_server(gql)
13501350
'use :stop_server(...) instead of .stop_server(...)')
13511351
assert(gql.server, 'no running server to stop')
13521352

1353-
print (('The GraphQL server stopped at http://%s:%s'):format(
1354-
gql.server.host, gql.server.port))
1355-
13561353
gql.server:stop()
1354+
1355+
return ('The GraphQL server stopped at http://%s:%s'):format(
1356+
gql.server.host, gql.server.port)
13571357
end
13581358

13591359
function tarantool_graphql.compile(query)

test/common/array_and_map.test.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env tarantool
2+
3+
local fio = require('fio')
4+
5+
-- require in-repo version of graphql/ sources despite current working directory
6+
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
7+
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
8+
9+
local test_utils = require('test.utils')
10+
local testdata = require('test.testdata.array_and_map_testdata')
11+
12+
box.cfg({})
13+
14+
test_utils.run_testdata(testdata)
15+
16+
os.exit()

test/common/avro_refs.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.avro_refs_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

test/common/common.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.common_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

test/common/compound_index.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.compound_index_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

test/common/directives.test.lua

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/usr/bin/env tarantool
2+
3+
local fio = require('fio')
4+
5+
-- require in-repo version of graphql/ sources despite current working directory
6+
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
7+
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
8+
9+
local tap = require('tap')
10+
local yaml = require('yaml')
11+
local utils = require('graphql.utils')
12+
local test_utils = require('test.utils')
13+
local testdata = require('test.testdata.common_testdata')
14+
15+
local function run_queries(gql_wrapper)
16+
local test = tap.test('directives')
17+
test:plan(4)
18+
19+
local query_1 = [[
20+
query user_by_order($first_name: String, $description: String,
21+
$include: Boolean) {
22+
order_collection(description: $description) {
23+
order_id
24+
description
25+
user_connection @include(if: $include,
26+
first_name: $first_name) {
27+
user_id
28+
last_name
29+
first_name
30+
}
31+
}
32+
}
33+
]]
34+
35+
local gql_query_1 = utils.show_trace(function()
36+
return gql_wrapper:compile(query_1)
37+
end)
38+
39+
-- {{{ 1_1
40+
41+
local variables_1_1 = {
42+
first_name = 'Ivan',
43+
description = 'first order of Ivan',
44+
include = true
45+
}
46+
47+
-- should match 1 user
48+
local result_1_1 = utils.show_trace(function()
49+
return gql_query_1:execute(variables_1_1)
50+
end)
51+
52+
local exp_result_1_1 = yaml.decode(([[
53+
---
54+
order_collection:
55+
- order_id: order_id_1
56+
description: first order of Ivan
57+
user_connection:
58+
user_id: user_id_1
59+
last_name: Ivanov
60+
first_name: Ivan
61+
]]):strip())
62+
63+
test:is_deeply(result_1_1, exp_result_1_1, '1_1')
64+
65+
-- }}}
66+
-- {{{ 1_2
67+
68+
local variables_1_2 = {
69+
first_name = 'Ivan',
70+
description = 'first order of Ivan',
71+
include = false
72+
}
73+
74+
local result_1_2 = utils.show_trace(function()
75+
return gql_query_1:execute(variables_1_2)
76+
end)
77+
78+
local exp_result_1_2 = yaml.decode(([[
79+
---
80+
order_collection:
81+
- order_id: order_id_1
82+
description: first order of Ivan
83+
]]):strip())
84+
85+
test:is_deeply(result_1_2, exp_result_1_2, '1_2')
86+
87+
-- }}}
88+
89+
local query_2 = [[
90+
query user_by_order($first_name: String, $description: String, $skip: Boolean) {
91+
order_collection(description: $description) {
92+
order_id
93+
description
94+
user_connection @skip(if: $skip, first_name: $first_name) {
95+
user_id
96+
last_name
97+
first_name
98+
}
99+
}
100+
}
101+
]]
102+
103+
local gql_query_2 = utils.show_trace(function()
104+
return gql_wrapper:compile(query_2)
105+
end)
106+
107+
-- {{{ 2_1
108+
109+
local variables_2_1 = {
110+
first_name = 'Ivan',
111+
description = 'first order of Ivan',
112+
skip = true
113+
}
114+
115+
local result_2_1 = utils.show_trace(function()
116+
return gql_query_2:execute(variables_2_1)
117+
end)
118+
119+
local exp_result_2_1 = yaml.decode(([[
120+
---
121+
order_collection:
122+
- order_id: order_id_1
123+
description: first order of Ivan
124+
]]):strip())
125+
126+
test:is_deeply(result_2_1, exp_result_2_1, '2_1')
127+
128+
-- }}}
129+
-- {{{ 2_2
130+
131+
local variables_2_2 = {
132+
first_name = 'Ivan',
133+
description = 'first order of Ivan',
134+
skip = false
135+
}
136+
137+
local result_2_2 = utils.show_trace(function()
138+
return gql_query_2:execute(variables_2_2)
139+
end)
140+
141+
local exp_result_2_2 = yaml.decode(([[
142+
---
143+
order_collection:
144+
- order_id: order_id_1
145+
description: first order of Ivan
146+
user_connection:
147+
user_id: user_id_1
148+
last_name: Ivanov
149+
first_name: Ivan
150+
]]):strip())
151+
152+
test:is_deeply(result_2_2, exp_result_2_2, '2_2')
153+
154+
-- }}}
155+
156+
assert(test:check(), 'check plan')
157+
end
158+
159+
160+
box.cfg({})
161+
162+
test_utils.run_testdata(testdata, {
163+
run_queries = run_queries,
164+
})
165+
166+
os.exit()

test/common/limit_result.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

99
local tap = require('tap')
10-
local utils = require('test.utils')
10+
local test_utils = require('test.utils')
1111
local testdata = require('test.testdata.user_order_item_testdata')
1212

1313
local function run_queries(gql_wrapper)
@@ -53,7 +53,7 @@ end
5353

5454
box.cfg({})
5555

56-
utils.run_testdata(testdata, {
56+
test_utils.run_testdata(testdata, {
5757
run_queries = run_queries,
5858
graphql_opts = {
5959
resulting_object_cnt_max = 3,

test/common/multihead_conn.test.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env tarantool
2+
3+
local fio = require('fio')
4+
5+
-- require in-repo version of graphql/ sources despite current working directory
6+
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
7+
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
8+
9+
local test_utils = require('test.utils')
10+
local testdata = require('test.testdata.multihead_conn_testdata')
11+
12+
box.cfg({})
13+
14+
test_utils.run_testdata(testdata)
15+
16+
os.exit()

test/common/nested_record.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.nested_record_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

test/common/nullable_1_1_conn.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.nullable_1_1_conn_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

test/common/nullable_index.test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ local fio = require('fio')
66
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
77
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
88

9-
local utils = require('test.utils')
9+
local test_utils = require('test.utils')
1010
local testdata = require('test.testdata.nullable_index_testdata')
1111

1212
box.cfg({})
1313

14-
utils.run_testdata(testdata)
14+
test_utils.run_testdata(testdata)
1515

1616
os.exit()

0 commit comments

Comments
 (0)