Skip to content

Commit b6161a0

Browse files
laurenceislasteve-chavez
authored andcommitted
test: the regression test queries now run faster
It doesn't call the main function that generates the OpenAPI spec directly anymore. It saves the output in a table and the tests will query that table instead (via a function).
1 parent 4ffebaa commit b6161a0

15 files changed

+410
-384
lines changed

test/expected/info.out

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
-- shows the first line of the comment on the schema as title
2-
select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'title');
2+
select jsonb_pretty(get_openapi_document('{test}')->'info'->'title');
33
jsonb_pretty
44
----------------
55
"My API title"
66
(1 row)
77

88
-- shows the second line of the comment on the schema as summary
9-
select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'summary');
9+
select jsonb_pretty(get_openapi_document('{test}')->'info'->'summary');
1010
jsonb_pretty
1111
------------------
1212
"My API summary"
1313
(1 row)
1414

1515
-- shows the third line of the comment on the schema as description
16-
select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'description');
16+
select jsonb_pretty(get_openapi_document('{test}')->'info'->'description');
1717
jsonb_pretty
1818
--------------------------------------------------
1919
"My API description\nthat spans\nmultiple lines"
2020
(1 row)
2121

2222
-- shows default title when there is no comment on the schema
23-
select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'title');
23+
select jsonb_pretty(get_openapi_document('{types}')->'info'->'title');
2424
jsonb_pretty
2525
-----------------
2626
"PostgREST API"
2727
(1 row)
2828

2929
-- shows no summary when there is no comment on the schema
30-
select postgrest_openapi_spec('{types}')->'info' ? 'summary';
30+
select get_openapi_document('{types}')->'info' ? 'summary';
3131
?column?
3232
----------
3333
f
3434
(1 row)
3535

3636

3737
-- shows default description when there is no comment on the schema
38-
select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'description');
38+
select jsonb_pretty(get_openapi_document('{types}')->'info'->'description');
3939
jsonb_pretty
4040
------------------------------------------------
4141
"This is a dynamic API generated by PostgREST"

test/expected/parameters.out

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- shows common query parameters
22
select *
3-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
3+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
44
where key in ('select', 'order', 'limit', 'offset', 'on_conflict', 'columns', 'or', 'and', 'not.or', 'not.and');
55
key | value
66
-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -18,7 +18,7 @@ where key in ('select', 'order', 'limit', 'offset', 'on_conflict', 'columns', 'o
1818

1919
-- shows common headers
2020
select key, jsonb_pretty(value)
21-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
21+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
2222
where key in ('preferGet', 'preferPost', 'preferPut', 'preferPatch', 'preferDelete', 'preferPostRpc', 'range');
2323
key | jsonb_pretty
2424
---------------+------------------------------------------------------------------------------
@@ -283,7 +283,7 @@ where key in ('preferGet', 'preferPost', 'preferPut', 'preferPatch', 'preferDele
283283

284284
-- shows table columns as parameters
285285
select key, jsonb_pretty(value)
286-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
286+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
287287
where key like 'rowFilter.products.%';
288288
key | jsonb_pretty
289289
--------------------------------+----------------------------
@@ -333,7 +333,7 @@ where key like 'rowFilter.products.%';
333333

334334
-- shows view columns as parameters
335335
select key, jsonb_pretty(value)
336-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
336+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
337337
where key like 'rowFilter.big_products.%';
338338
key | jsonb_pretty
339339
-----------------------------+--------------------------
@@ -369,7 +369,7 @@ where key like 'rowFilter.big_products.%';
369369

370370
-- shows `IN` function arguments as RPC parameters
371371
select key, jsonb_pretty(value)
372-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
372+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
373373
where key like 'rpcParam.has_in_parameters.%';
374374
key | jsonb_pretty
375375
------------------------------+-----------------------------------------
@@ -413,7 +413,7 @@ where key like 'rpcParam.has_in_parameters.%';
413413

414414
-- shows `INOUT` function arguments as RPC parameters
415415
select key, jsonb_pretty(value)
416-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
416+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
417417
where key like 'rpcParam.has_inout_parameters.%';
418418
key | jsonb_pretty
419419
---------------------------------+-----------------------------------------
@@ -457,7 +457,7 @@ where key like 'rpcParam.has_inout_parameters.%';
457457

458458
-- shows `VARIADIC` function arguments as RPC parameters
459459
select key, jsonb_pretty(value)
460-
from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters')
460+
from jsonb_each(get_openapi_document('{test}')->'components'->'parameters')
461461
where key like 'rpcParam.has_variadic_parameter.%';
462462
key | jsonb_pretty
463463
-----------------------------------+-----------------------------------

0 commit comments

Comments
 (0)