fix to really execute plugins in order (#8018)
This commit is contained in:
parent
3f9d443b1e
commit
6163231ef6
2 changed files with 31 additions and 6 deletions
23
rootfs/etc/nginx/lua/test/plugins_test.lua
Normal file
23
rootfs/etc/nginx/lua/test/plugins_test.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
describe("plugins", function()
|
||||
describe("#run", function()
|
||||
it("runs the plugins in the given order", function()
|
||||
ngx.get_phase = function() return "rewrite" end
|
||||
local plugins = require("plugins")
|
||||
local called_plugins = {}
|
||||
local plugins_to_mock = {"plugins.pluginfirst.main", "plugins.pluginsecond.main", "plugins.pluginthird.main"}
|
||||
for i=1, 3, 1
|
||||
do
|
||||
package.loaded[plugins_to_mock[i]] = {
|
||||
rewrite = function()
|
||||
called_plugins[#called_plugins + 1] = plugins_to_mock[i]
|
||||
end
|
||||
}
|
||||
end
|
||||
assert.has_no.errors(function()
|
||||
plugins.init({"pluginfirst", "pluginsecond", "pluginthird"})
|
||||
end)
|
||||
assert.has_no.errors(plugins.run)
|
||||
assert.are.same(plugins_to_mock, called_plugins)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue