Skip to content

Commit 5a9da18

Browse files
committed
Test: fix pingpong.t to align with stream route validation and add cleanup. Fixed status code check in pingpong test to ensure correct error message is output when 400 error is returned
1. Update TEST 15 to expect 400 when creating a route with a non-existent superior_id, reflecting the new validation logic. 2. Add TEST 22 to clean up created stream routes after tests to prevent Etcd data pollution affecting subsequent tests (e.g., redis.t). Signed-off-by: Orician <[email protected]>
1 parent 0d98bb6 commit 5a9da18

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

t/admin/stream-routes-subordinate.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ passed
147147
}
148148
}]]
149149
)
150-
150+
151151
local code, body = t('/apisix/admin/stream_routes/5',
152152
ngx.HTTP_PUT,
153153
[[{

t/xrpc/pingpong.t

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ call pingpong's log, ctx unfinished: false
510510
}
511511
}
512512
)
513-
if code >= 300 then
513+
if code ~= 400 then
514514
ngx.status = code
515-
ngx.say(body)
515+
ngx.say("expected 400 for invalid superior_id, got " .. code .. ": " .. body)
516516
return
517517
end
518518
@@ -779,3 +779,47 @@ qr/connect to \S+ while prereading client data/
779779
connect to 127.0.0.3:1995 while prereading client data
780780
connect to 127.0.0.1:1995 while prereading client data
781781
--- stream_conf_enable
782+
783+
=== TEST 22: cleanup
784+
--- config
785+
location /t {
786+
content_by_lua_block {
787+
local t = require("lib.test_admin").test
788+
789+
-- Delete dependent routes first
790+
local code, body = t('/apisix/admin/stream_routes/2', ngx.HTTP_DELETE)
791+
if code >= 300 then
792+
ngx.status = code
793+
ngx.say(body)
794+
return
795+
end
796+
797+
local code, body = t('/apisix/admin/stream_routes/3', ngx.HTTP_DELETE)
798+
if code >= 300 then
799+
ngx.status = code
800+
ngx.say(body)
801+
return
802+
end
803+
804+
local code, body = t('/apisix/admin/stream_routes/5', ngx.HTTP_DELETE)
805+
if code >= 300 then
806+
ngx.status = code
807+
ngx.say(body)
808+
return
809+
end
810+
811+
-- Then delete the superior route
812+
local code, body = t('/apisix/admin/stream_routes/1', ngx.HTTP_DELETE)
813+
if code >= 300 then
814+
ngx.status = code
815+
ngx.say(body)
816+
return
817+
end
818+
819+
ngx.say("passed")
820+
}
821+
}
822+
--- request
823+
GET /t
824+
--- response_body
825+
passed

0 commit comments

Comments
 (0)