From 17ab7dc3b2928e2e8c4bf5cec583c5a94d74fc81 Mon Sep 17 00:00:00 2001 From: Xiaochen Wang Date: Tue, 26 Nov 2024 17:41:15 +0800 Subject: [PATCH] test more page_size: nil, 512, 2049 --- .../11-dbless/04-pagination_spec.lua | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/spec/02-integration/11-dbless/04-pagination_spec.lua b/spec/02-integration/11-dbless/04-pagination_spec.lua index bcda8b940123..235d6fbdecd4 100644 --- a/spec/02-integration/11-dbless/04-pagination_spec.lua +++ b/spec/02-integration/11-dbless/04-pagination_spec.lua @@ -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, { @@ -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, @@ -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) @@ -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)