kong-pongo
kong-pongo copied to clipboard
Can't run integration tests in purely DB-less mode
I'm developing a plugin using the kong-plugin
template. After cloning the template I switched the for loop in the integration spec from
for _, strategy in helpers.all_strategies() do
to
for _, strategy in ipairs({"off"}) do
This causes pongo
to throw the following error:
[----------] Global test environment setup.
[----------] Running tests from /kong-plugin/spec/myplugin/01-unit_spec.lua
2022/08/02 05:54:47 [warn] [Penlight 1.12.0] the contents of module 'pl.text' has moved into 'pl.stringx' (deprecated after 1.11.0, scheduled for removal in 2.0.0)
[ RUN ] /kong-plugin/spec/myplugin/01-unit_spec.lua @ 18: myplugin: (schema) accepts distinct request_header and response_header
[ OK ] /kong-plugin/spec/myplugin/01-unit_spec.lua @ 18: myplugin: (schema) accepts distinct request_header and response_header (1.69 ms)
[ RUN ] /kong-plugin/spec/myplugin/01-unit_spec.lua @ 28: myplugin: (schema) does not accept identical request_header and response_header
[ OK ] /kong-plugin/spec/myplugin/01-unit_spec.lua @ 28: myplugin: (schema) does not accept identical request_header and response_header (1.54 ms)
[----------] 2 tests from /kong-plugin/spec/myplugin/01-unit_spec.lua (1317.18 ms total)
[----------] Running tests from /kong-plugin/spec/myplugin/02-integration_spec.lua
./spec/helpers.lua:171: Error: 'kong config db_export' only works with a database.
Run with --v (verbose) or --vv (debug) for more details
stack traceback:
./spec/helpers.lua:171: in function 'make_yaml_file'
/kong-plugin/spec/myplugin/02-integration_spec.lua:36: in function </kong-plugin/spec/myplugin/02-integration_spec.lua:11>
[----------] 0 tests from /kong-plugin/spec/myplugin/02-integration_spec.lua (3293.07 ms total)
[----------] Global test environment teardown.
[==========] 2 tests from 2 test files ran. (4610.82 ms total)
[ PASSED ] 2 tests.
[ ERROR ] 1 error, listed below:
[ ERROR ] /kong-plugin/spec/myplugin/02-integration_spec.lua @ 11: myplugin: (access) [#off] lazy_setup
1 ERROR
ERROR: 1
However if I run the postgres
strategy first, then the DB-less strategy works. Any suggestions on how I can get this working for just DB-less?
Check the original template. It requires a Postgres db. Even for db less, since the test helpers wrote to the db. Only when running db less tests it exports and starts db less.
EDIT: typo
I assume this is fixed, hence closing. Please reopen if not.
It's time and resource-consuming for the build, why do I need to have postgres db if I'm using db-less. I believe refactor for test helpers is required here to accommodate the db-less as well.
Also what is the point of having like this --no-postgres --no-cassandra
I will be always getting similar error response for Cassandra as well
This test tool caters for a wider audience than just the DB-less. You get some, you loose some.