From c4231f040b2ae37bc865ee64f01797b7c69afd98 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Tabata Date: Fri, 24 Aug 2018 10:36:28 +0900 Subject: [PATCH] modify unit test --- spec/resty/limit/count-inc_spec.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/resty/limit/count-inc_spec.lua b/spec/resty/limit/count-inc_spec.lua index e22926cb5..5ac9d4ce4 100644 --- a/spec/resty/limit/count-inc_spec.lua +++ b/spec/resty/limit/count-inc_spec.lua @@ -77,10 +77,14 @@ describe('resty.limit.count-inc', function() describe('and incr method fails', function() it('returns error', function() - lim:incoming('tmp', true) - ngx.shared.limiter.incr = function() - return nil, 'something' + ngx.shared.limiter.incr = function(t, key, inc, init, _) + local value = t:get(key) or init + if not value then return nil, 'not found' end + if inc == -1 then return nil, 'something' end + t:set(key, value + inc) + return t:get(key) end + lim:incoming('tmp', true) local delay, err = lim:incoming('tmp', true) assert.is_nil(delay) assert.same('something', err)