Skip to content

Commit ebe9be4

Browse files
Test argument and variable nullability
Compare library with JS reference implementation in various nullability cases. This patch uses JS script to build various schemas and queries and execute them to generate luatest script that verifies that this library has the same behavior. To generate script, run ```bash cd ./tests/integration/codegen/fuzzing_nullability npm install node ./generate.js > ../../fuzzing_nullability_test.lua ``` Prior to this patch, several nullability behavior issues were fixed. There is some case that isn't yet fully covered by our library, refer to [1] for updates. Follow [2] for more test cases. Based on @no1seman PR [3]. 1. #62 2. #63 3. #59
1 parent 60a1145 commit ebe9be4

File tree

10 files changed

+153185
-122
lines changed

10 files changed

+153185
-122
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ coverage_result.txt
2424
.DS_Store
2525
.vscode
2626
luacov.*.out*
27-
/node_modules
27+
**/node_modules
2828
/package-lock.json
2929
*.mo
3030
.history

.luacheckrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include_files = {
88
}
99
exclude_files = {
1010
'.rocks',
11+
'test/integration/fuzzing_nullability_test.lua',
1112
}
1213
new_read_globals = {
1314
box = { fields = {

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SHELL := /bin/bash
33
.PHONY: .rocks
44
.rocks: graphql-scm-1.rockspec Makefile
55
tarantoolctl rocks make
6-
tarantoolctl rocks install luatest 0.5.5
6+
tarantoolctl rocks install luatest 0.5.7
77
tarantoolctl rocks install luacov 0.13.0
88
tarantoolctl rocks install luacheck 0.26.0
99

test/helpers.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
local types = require('graphql.types')
2+
local schema = require('graphql.schema')
3+
local parse = require('graphql.parse')
4+
local validate = require('graphql.validate')
5+
local execute = require('graphql.execute')
6+
7+
local helpers = {}
8+
9+
helpers.test_schema_name = 'default'
10+
11+
function helpers.check_request(query, query_schema, mutation_schema, directives, opts)
12+
opts = opts or {}
13+
local root = {
14+
query = types.object({
15+
name = 'Query',
16+
fields = query_schema or {},
17+
}),
18+
mutation = types.object({
19+
name = 'Mutation',
20+
fields = mutation_schema or {},
21+
}),
22+
directives = directives,
23+
}
24+
25+
local compiled_schema = schema.create(root, helpers.test_schema_name, opts)
26+
27+
local parsed = parse.parse(query)
28+
29+
validate.validate(compiled_schema, parsed)
30+
31+
local rootValue = {}
32+
local variables = opts.variables or {}
33+
return execute.execute(compiled_schema, parsed, rootValue, variables)
34+
end
35+
36+
return helpers
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To install dependencies, run
2+
```bash
3+
npm install
4+
```
5+
6+
To generate test file, run
7+
```bash
8+
node generate.js > ../../fuzzing_nullability_test.lua
9+
```
10+
in this directory.

0 commit comments

Comments
 (0)