Testing, busted, postgres

Following the example from https://docs.konghq.com/2.2.x/plugin-development/tests/
I am successfully running tests using Cassandra DB;

Is it possible to run these test using Postgres DB ?

When I set KONG_DATABASE=postgres , that value is nil inside the helper.lua and my code enumerate the default set (postgres, cassandra) failing on non existing strategy=cassandra. If I change the name of env variable to anything but KONG_DATABASE , everything works perfectly; for example KKONG_DATABASE=postgres? But that requires me to change the helpers.lua code?

I have notice that in case of tests setup with cassandra; following code also enumerates strategies <postgres, cassandra> but somehow postgres is ignored and tests are succeeding?

local helpers = require “spec.helpers”

for _, strategy in helpers.each_strategy() do
describe(“my plugin”, function()

Can you paste the command line you are using to run the tests, please?

When running with busted both Cassandra and Postgres strategies should be tested, by default. To ease the process, you can use kong-tests-compose to run all the dependencies needed.

I want to restrict it only to postgres

cd /home/kong-api-gateway-plugins/build/kong-src-2.1.3 && DIGEST_USER=x DIGEST_PASSWORD=x KONG_DATABASE=postgres ANONYMOUS_USER_ID=x KONG_SPEC_TEST_CONF_PATH=/home/kong-api-gateway-plugins/build/spec/kong.conf /home/kong-api-gateway-plugins/build/kong-src-2.1.3/bin/busted -v -o gtest -C /home/kong-api-gateway-plugins/build/kong-src-2.1.3 --coverage --lpath=’?.lua;./src/?.lua;./src/?/?.lua;./src/?/init.lua’ --cpath=’./csrc/?.so;./csrc/?/?.so;;’ /home/kong-api-gateway-plugins/spec/plugins/test-plugin -o gtest;

Sorry, it slipped me the var name you mentioned in the original message. The env var you want to set is KONG_TEST_DATABASE=postgres, that’s the one used by busted.

Thank you very much , that resolved my issue

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ