Skip to content

Commit

Permalink
spec/configuration/service: add test for backwards compat with extrac…
Browse files Browse the repository at this point in the history
…t_usage()
  • Loading branch information
davidor committed Dec 14, 2017
1 parent 3b1c04c commit bc608fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/configuration/service_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,20 @@ describe('Service object', function()

end)
end)

describe(':get_usage', function()
describe('when the old and deprecated extract_usage method is defined', function()
it('is called. To keep backwards compatibility', function()
local service = Service.new({
extract_usage = function() return 42 end
})

-- Used in the code, need to initialize it.
ngx.var = { request = 'GET /' }

local usage = service:get_usage('GET', '/')
assert.equal(42, usage)
end)
end)
end)
end)

0 comments on commit bc608fc

Please sign in to comment.