Skip to content

Commit

Permalink
chore(tests): cmd helpers import DB on demand
Browse files Browse the repository at this point in the history
This makes cmd helpers function available for env where no DB provided
  • Loading branch information
StarlightIbuki committed Dec 10, 2024
1 parent 96076c3 commit edf6f66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ local client = reload_module("spec.internal.client")
local wait = reload_module("spec.internal.wait")


-- redo the patches to make kong PDK available to timerng timers
require("spec.internal.module").reload("kong.globalpatches")({ cli = true, rbusted = true, })


----------------
-- Variables/constants
-- @section exported-fields
Expand Down
6 changes: 5 additions & 1 deletion spec/internal/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ local prefix_handler = require("kong.cmd.utils.prefix_handler")
local CONSTANTS = require("spec.internal.constants")
local conf = require("spec.internal.conf")
local shell = require("spec.internal.shell")
local DB = require("spec.internal.db")
local DB
local pid = require("spec.internal.pid")
local dns_mock = require("spec.internal.dns")

Expand Down Expand Up @@ -263,6 +263,10 @@ end
--
-- assert(helpers.start_kong( {database = "postgres"}, nil, nil, fixtures))
local function start_kong(env, tables, preserve_prefix, fixtures)
if not DB then
DB = require("spec.internal.db")
end

if tables ~= nil and type(tables) ~= "table" then
error("arg #2 must be a list of tables to truncate")
end
Expand Down

0 comments on commit edf6f66

Please sign in to comment.