refactor some lua code
This commit is contained in:
parent
ced6c5bd96
commit
cb4755835e
11 changed files with 83 additions and 47 deletions
20
rootfs/etc/nginx/lua/test/defer_test.lua
Normal file
20
rootfs/etc/nginx/lua/test/defer_test.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package.path = "./rootfs/etc/nginx/lua/?.lua;./rootfs/etc/nginx/lua/test/mocks/?.lua;" .. package.path
|
||||
_G._TEST = true
|
||||
local defer = require('util.defer')
|
||||
|
||||
local _ngx = {
|
||||
shared = {},
|
||||
log = function(...) end,
|
||||
get_phase = function() return "timer" end,
|
||||
}
|
||||
_G.ngx = _ngx
|
||||
|
||||
describe("Defer", function()
|
||||
describe("to_timer_phase", function()
|
||||
it("executes passed callback immediately if called on timer phase", function()
|
||||
defer.counter = 0
|
||||
defer.to_timer_phase(function() defer.counter = defer.counter + 1 end)
|
||||
assert.equal(defer.counter, 1)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue