Skip to content

Commit

Permalink
add page rows number
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Nov 26, 2024
1 parent 54ab4ff commit 24521c4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions spec/02-integration/11-dbless/04-pagination_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ local SERVICE_YML = [[


describe("dbless pagination #off", function()
local client

lazy_setup(function()
assert(helpers.start_kong({
nginx_conf = "spec/fixtures/custom_nginx.template",
database = "off",
plugins = "bundled,dbless-pagination-test",
}))
print("helpers.start_kong")

client = assert(helpers.proxy_client())
end)

lazy_teardown(function()
client:close()
helpers.stop_kong()
end)

Expand All @@ -45,5 +50,21 @@ describe("dbless pagination #off", function()
assert.res_status(201, res)
admin_client:close()

local res = admin_client:get("/routes/my-route-1")
print(res:read_body())
print("-------")

-- check routes number with :page() API
--local res, err = client:get("/1", {})

local res = assert(client:send {
method = "GET",
path = "/1",
})
--print(require("inspect")(res))
local resbody = res:read_body()
print"--------"
print(resbody)
--assert.response(res).has.header("X-rows-number", "test")
end)
end)
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ function LmdbPaginationTestHandler:init_worker()
ngx.timer.at(0, test)
end

function LmdbPaginationTestHandler:access(conf)
ngx.log(ngx.INFO, "xxxxxxxxxxxxxx")
local rows, err, err_t, offset = kong.db.routes:page()

ngx.header["X-rows-number"] = #rows
end


return LmdbPaginationTestHandler
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
return {
name = "dns-client-test",
name = "dbless-pagination-test",
fields = {
{
config = {
Expand Down

0 comments on commit 24521c4

Please sign in to comment.