Skip to content

Commit b7eaca4

Browse files
DifferentialOrangeTotktonada
authored andcommitted
Improve test coverage
Last entries line in multiline table considered as non-covered by luacov if it has no trailing comma. See more about the issue in luacov repo: lunarmodules/luacov#52 Based on PR #18 by @no1seman
1 parent cd375d0 commit b7eaca4

File tree

6 files changed

+99
-95
lines changed

6 files changed

+99
-95
lines changed

graphql/execute.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ local function getFieldEntry(objectType, object, fields, context)
278278
if argument and argument.value then
279279
positions[pos] = {
280280
name=argument.name.value,
281-
value=arguments[argument.name.value]
281+
value=arguments[argument.name.value],
282282
}
283283
pos = pos + 1
284284
end
@@ -345,4 +345,6 @@ local function execute(schema, tree, rootValue, variables, operationName)
345345
end
346346

347347

348-
return {execute=execute}
348+
return {
349+
execute = execute,
350+
}

graphql/introspection.lua

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ __Schema = types.object({
3939
kind = types.nonNull(types.list(types.nonNull(__Type))),
4040
resolve = function(schema)
4141
return util.values(schema:getTypeMap())
42-
end
42+
end,
4343
},
4444

4545
queryType = {
4646
description = 'The type that query operations will be rooted at.',
4747
kind = __Type.nonNull,
4848
resolve = function(schema)
4949
return schema:getQueryType()
50-
end
50+
end,
5151
},
5252

5353
mutationType = {
5454
description = 'If this server supports mutation, the type that mutation operations will be rooted at.',
5555
kind = __Type,
5656
resolve = function(schema)
5757
return schema:getMutationType()
58-
end
58+
end,
5959
},
6060

6161
subscriptionType = {
6262
description = 'If this server supports mutation, the type that mutation operations will be rooted at.',
6363
kind = __Type,
6464
resolve = function(_)
6565
return nil
66-
end
66+
end,
6767
},
6868

6969

@@ -72,10 +72,10 @@ __Schema = types.object({
7272
kind = types.nonNull(types.list(types.nonNull(__Directive))),
7373
resolve = function(schema)
7474
return schema.directives
75-
end
76-
}
75+
end,
76+
},
7777
}
78-
end
78+
end,
7979
})
8080

8181
__Directive = types.object({
@@ -111,15 +111,15 @@ __Directive = types.object({
111111
if directive.onInlineFragment then table.insert(res, 'INLINE_FRAGMENT') end
112112

113113
return res
114-
end
114+
end,
115115
},
116116

117117
args = {
118118
kind = types.nonNull(types.list(types.nonNull(__InputValue))),
119-
resolve = resolveArgs
120-
}
119+
resolve = resolveArgs,
120+
},
121121
}
122-
end
122+
end,
123123
})
124124

125125
__DirectiveLocation = types.enum({
@@ -133,34 +133,34 @@ __DirectiveLocation = types.enum({
133133
values = {
134134
QUERY = {
135135
value = 'QUERY',
136-
description = 'Location adjacent to a query operation.'
136+
description = 'Location adjacent to a query operation.',
137137
},
138138

139139
MUTATION = {
140140
value = 'MUTATION',
141-
description = 'Location adjacent to a mutation operation.'
141+
description = 'Location adjacent to a mutation operation.',
142142
},
143143

144144
FIELD = {
145145
value = 'FIELD',
146-
description = 'Location adjacent to a field.'
146+
description = 'Location adjacent to a field.',
147147
},
148148

149149
FRAGMENT_DEFINITION = {
150150
value = 'FRAGMENT_DEFINITION',
151-
description = 'Location adjacent to a fragment definition.'
151+
description = 'Location adjacent to a fragment definition.',
152152
},
153153

154154
FRAGMENT_SPREAD = {
155155
value = 'FRAGMENT_SPREAD',
156-
description = 'Location adjacent to a fragment spread.'
156+
description = 'Location adjacent to a fragment spread.',
157157
},
158158

159159
INLINE_FRAGMENT = {
160160
value = 'INLINE_FRAGMENT',
161-
description = 'Location adjacent to an inline fragment.'
162-
}
163-
}
161+
description = 'Location adjacent to an inline fragment.',
162+
},
163+
},
164164
})
165165

166166
__Type = types.object({
@@ -205,16 +205,16 @@ __Type = types.object({
205205
end
206206

207207
error('Unknown type ' .. kind)
208-
end
208+
end,
209209
},
210210

211211
fields = {
212212
kind = types.list(types.nonNull(__Field)),
213213
arguments = {
214214
includeDeprecated = {
215215
kind = types.boolean,
216-
defaultValue = false
217-
}
216+
defaultValue = false,
217+
},
218218
},
219219
resolve = function(kind, arguments)
220220
if kind.__type == 'Object' or kind.__type == 'Interface' then
@@ -233,7 +233,7 @@ __Type = types.object({
233233
if kind.__type == 'Object' then
234234
return kind.interfaces or {}
235235
end
236-
end
236+
end,
237237
},
238238

239239
possibleTypes = {
@@ -242,21 +242,21 @@ __Type = types.object({
242242
if kind.__type == 'Interface' or kind.__type == 'Union' then
243243
return context.schema:getPossibleTypes(kind)
244244
end
245-
end
245+
end,
246246
},
247247

248248
enumValues = {
249249
kind = types.list(types.nonNull(__EnumValue)),
250250
arguments = {
251-
includeDeprecated = { kind = types.boolean, defaultValue = false }
251+
includeDeprecated = { kind = types.boolean, defaultValue = false },
252252
},
253253
resolve = function(kind, arguments)
254254
if kind.__type == 'Enum' then
255255
return util.filter(util.values(kind.values), function(value)
256256
return arguments.includeDeprecated or not value.deprecationReason
257257
end)
258258
end
259-
end
259+
end,
260260
},
261261

262262
inputFields = {
@@ -265,14 +265,14 @@ __Type = types.object({
265265
if kind.__type == 'InputObject' then
266266
return util.values(kind.fields)
267267
end
268-
end
268+
end,
269269
},
270270

271271
ofType = {
272-
kind = __Type
273-
}
272+
kind = __Type,
273+
},
274274
}
275-
end
275+
end,
276276
})
277277

278278
__Field = types.object({
@@ -290,26 +290,26 @@ __Field = types.object({
290290

291291
args = {
292292
kind = types.nonNull(types.list(types.nonNull(__InputValue))),
293-
resolve = resolveArgs
293+
resolve = resolveArgs,
294294
},
295295

296296
type = {
297297
kind = __Type.nonNull,
298298
resolve = function(field)
299299
return field.kind
300-
end
300+
end,
301301
},
302302

303303
isDeprecated = {
304304
kind = types.boolean.nonNull,
305305
resolve = function(field)
306306
return field.deprecationReason ~= nil
307-
end
307+
end,
308308
},
309309

310-
deprecationReason = types.string
310+
deprecationReason = types.string,
311311
}
312-
end
312+
end,
313313
})
314314

315315
__InputValue = types.object({
@@ -330,18 +330,18 @@ __InputValue = types.object({
330330
kind = types.nonNull(__Type),
331331
resolve = function(field)
332332
return field.kind
333-
end
333+
end,
334334
},
335335

336336
defaultValue = {
337337
kind = types.string,
338338
description = 'A GraphQL-formatted string representing the default value for this input value.',
339339
resolve = function(inputVal)
340340
return inputVal.defaultValue and tostring(inputVal.defaultValue) -- TODO improve serialization a lot
341-
end
342-
}
341+
end,
342+
},
343343
}
344-
end
344+
end,
345345
})
346346

347347
__EnumValue = types.object({
@@ -361,9 +361,9 @@ __EnumValue = types.object({
361361
kind = types.boolean.nonNull,
362362
resolve = function(enumValue) return enumValue.deprecationReason ~= nil end
363363
},
364-
deprecationReason = types.string
364+
deprecationReason = types.string,
365365
}
366-
end
366+
end,
367367
})
368368

369369
__TypeKind = types.enum({
@@ -372,44 +372,44 @@ __TypeKind = types.enum({
372372
values = {
373373
SCALAR = {
374374
value = 'SCALAR',
375-
description = 'Indicates this type is a scalar.'
375+
description = 'Indicates this type is a scalar.',
376376
},
377377

378378
OBJECT = {
379379
value = 'OBJECT',
380-
description = 'Indicates this type is an object. `fields` and `interfaces` are valid fields.'
380+
description = 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
381381
},
382382

383383
INTERFACE = {
384384
value = 'INTERFACE',
385-
description = 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.'
385+
description = 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
386386
},
387387

388388
UNION = {
389389
value = 'UNION',
390-
description = 'Indicates this type is a union. `possibleTypes` is a valid field.'
390+
description = 'Indicates this type is a union. `possibleTypes` is a valid field.',
391391
},
392392

393393
ENUM = {
394394
value = 'ENUM',
395-
description = 'Indicates this type is an enum. `enumValues` is a valid field.'
395+
description = 'Indicates this type is an enum. `enumValues` is a valid field.',
396396
},
397397

398398
INPUT_OBJECT = {
399399
value = 'INPUT_OBJECT',
400-
description = 'Indicates this type is an input object. `inputFields` is a valid field.'
400+
description = 'Indicates this type is an input object. `inputFields` is a valid field.',
401401
},
402402

403403
LIST = {
404404
value = 'LIST',
405-
description = 'Indicates this type is a list. `ofType` is a valid field.'
405+
description = 'Indicates this type is a list. `ofType` is a valid field.',
406406
},
407407

408408
NON_NULL = {
409409
value = 'NON_NULL',
410-
description = 'Indicates this type is a non-null. `ofType` is a valid field.'
411-
}
412-
}
410+
description = 'Indicates this type is a non-null. `ofType` is a valid field.',
411+
},
412+
},
413413
})
414414

415415
local Schema = {
@@ -419,19 +419,19 @@ local Schema = {
419419
arguments = {},
420420
resolve = function(_, _, info)
421421
return info.schema
422-
end
422+
end,
423423
}
424424

425425
local Type = {
426426
name = '__type',
427427
kind = __Type,
428428
description = 'Request the type information of a single type.',
429429
arguments = {
430-
name = types.string.nonNull
430+
name = types.string.nonNull,
431431
},
432432
resolve = function(_, arguments, info)
433433
return info.schema:getType(arguments.name)
434-
end
434+
end,
435435
}
436436

437437
local TypeName = {
@@ -441,7 +441,7 @@ local TypeName = {
441441
arguments = {},
442442
resolve = function(_, _, info)
443443
return info.parentType.name
444-
end
444+
end,
445445
}
446446

447447
return {
@@ -458,6 +458,6 @@ return {
458458
fieldMap = {
459459
__schema = Schema,
460460
__type = Type,
461-
__typename = TypeName
462-
}
461+
__typename = TypeName,
462+
},
463463
}

graphql/rules.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function rules.unambiguousSelections(node, context)
162162
local fieldEntry = {
163163
parent = parentType,
164164
field = selection,
165-
definition = definition
165+
definition = definition,
166166
}
167167

168168
validateField(key, fieldEntry)

graphql/schema.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function schema.create(config, name)
2121

2222
self.directives = self.directives or {
2323
types.include,
24-
types.skip
24+
types.skip,
2525
}
2626

2727
self.typeMap = {}

0 commit comments

Comments
 (0)