Skip to content

Commit

Permalink
test more page_size: nil, 512, 2049
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Nov 26, 2024
1 parent 7026271 commit 17ab7dc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions spec/02-integration/11-dbless/04-pagination_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local helpers = require "spec.helpers"
local strategy = "off"

describe("dbless pagination #" .. strategy, function()
local client, admin_client
local proxy_client, admin_client

lazy_setup(function()
local bp = helpers.get_db_utils(strategy, {
Expand All @@ -18,7 +18,7 @@ describe("dbless pagination #" .. strategy, function()
config = { },
}

for i = 1, 1001 do
for i = 1, 2050 do
local service = assert(bp.services:insert {
url = "https://example1.dev",
name = "my-serivce-" .. i,
Expand All @@ -32,19 +32,20 @@ describe("dbless pagination #" .. strategy, function()
end

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

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

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

Expand All @@ -53,12 +54,17 @@ describe("dbless pagination #" .. strategy, function()
local res = admin_client:get("/routes/my-route-1")
assert.res_status(200, res)

local res = assert(client:send {
method = "GET",
path = "/1",
})
local res = assert(proxy_client:get("/1?size=nil"))
assert.res_status(200, res)
assert.same(res.headers["X-Rows-Number"], "512")
assert.same(res.headers["X-Max-Page-Size"], "2048")

local res = assert(proxy_client:get("/1?size=2048"))
assert.res_status(200, res)
assert.same(res.headers["X-Rows-Number"], "512")

local res = assert(proxy_client:get("/1?size=2049"))
assert.res_status(200, res)
assert.same(res.headers["X-Rows-Number"], "[off] size must be an integer between 1 and 2048")
end)
end)

0 comments on commit 17ab7dc

Please sign in to comment.