Skip to content

Commit

Permalink
modify unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
y-tabata committed Sep 3, 2018
1 parent 85a1423 commit c4231f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions spec/resty/limit/count-inc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c4231f0

Please sign in to comment.