generalize cidr parsing and improve lua tests

This commit is contained in:
Elvin Efendi 2021-01-04 15:01:55 -05:00
parent 2254a91866
commit 2cff9fa41d
7 changed files with 68 additions and 70 deletions

View file

@ -1,15 +1,12 @@
function mock_ngx(mock)
local _ngx = mock
setmetatable(_ngx, {__index = _G.ngx})
_G.ngx = _ngx
end
describe("Balancer chash", function()
after_each(function()
reset_ngx()
end)
describe("balance()", function()
it("uses correct key for given backend", function()
mock_ngx({var = { request_uri = "/alma/armud"}})
local balancer_chash = require("balancer.chash")
ngx.var = { request_uri = "/alma/armud"}
local balancer_chash = require_without_cache("balancer.chash")
local resty_chash = package.loaded["resty.chash"]
resty_chash.new = function(self, nodes)