Skip to content

Commit

Permalink
with_current_ws
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 14, 2024
1 parent 32c9f85 commit 7b3a0f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 1 addition & 9 deletions spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1686,15 +1686,7 @@ end
-- Only use in CLI tests from spec/02-integration/01-cmd
kill_all = cmd.kill_all,

with_current_ws = function(ws,fn, db)
local old_ws = ngx.ctx.workspace
ngx.ctx.workspace = nil
ws = ws or {db.workspaces:select_by_name("default")}
ngx.ctx.workspace = ws[1] and ws[1].id
local res = fn()
ngx.ctx.workspace = old_ws
return res
end,
with_current_ws = misc.with_current_ws,

signal = cmd.signal,

Expand Down
12 changes: 12 additions & 0 deletions spec/internal/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ local function lookup(t, k)
end


local function with_current_ws(ws,fn, db)
local old_ws = ngx.ctx.workspace
ngx.ctx.workspace = nil
ws = ws or {db.workspaces:select_by_name("default")}
ngx.ctx.workspace = ws[1] and ws[1].id
local res = fn()
ngx.ctx.workspace = old_ws
return res
end


local make_temp_dir
do
local seeded = false
Expand Down Expand Up @@ -320,6 +331,7 @@ return {

lookup = lookup,

with_current_ws = with_current_ws,
make_temp_dir = make_temp_dir,
use_old_plugin = use_old_plugin,
}

0 comments on commit 7b3a0f6

Please sign in to comment.